summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-08-15 13:07:07 +0000
committered <ed@FreeBSD.org>2008-08-15 13:07:07 +0000
commitbd507c7cef0d90ce480caf8fccc35b5868afa229 (patch)
tree97fa442f4619eff0b084537b42202b5555ff9c24 /usr.sbin
parent311231d490d114d702898a3547094efcbd883851 (diff)
downloadFreeBSD-src-bd507c7cef0d90ce480caf8fccc35b5868afa229.zip
FreeBSD-src-bd507c7cef0d90ce480caf8fccc35b5868afa229.tar.gz
Convert the snp(4) driver to use cdevpriv.
Now we have a single /dev/snp device node, which can be opened by watch(8) multiple times. Even though snp(4) will be dead as of next week, it's nice having this in SVN, because: - We may want to MFC it to RELENG_7. - By the time we fix snp(4) again, it's already there, existing watch(8) binaries should already work. Just like bpf(4), I'm adding a symlink from snp0 to snp to remain binary compatible.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/watch/watch.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/usr.sbin/watch/watch.c b/usr.sbin/watch/watch.c
index cc833ef..388614e 100644
--- a/usr.sbin/watch/watch.c
+++ b/usr.sbin/watch/watch.c
@@ -152,30 +152,21 @@ fatal(int error, const char *buf)
static int
open_snp(void)
{
- char snp[] = {_PATH_DEV "snpXXX"};
- int f, mode, pos, c;
+ int f, mode;
- pos = strlen(snp) - 3;
if (opt_write)
mode = O_RDWR;
else
mode = O_RDONLY;
if (opt_snpdev == NULL)
- for (c = 0; c <= 999; c++) {
- snprintf(snp+pos, 4, "%d", c);
- if ((f = open(snp, mode)) < 0) {
- if (errno == EBUSY)
- continue;
- err(1, "open %s", snp);
- }
- return f;
- }
+ f = open(_PATH_DEV "snp", mode);
else
- if ((f = open(opt_snpdev, mode)) != -1)
- return (f);
- fatal(EX_OSFILE, "cannot open snoop device");
- return (0);
+ f = open(opt_snpdev, mode);
+ if (f == -1)
+ fatal(EX_OSFILE, "cannot open snoop device");
+
+ return (f);
}
OpenPOWER on IntegriCloud