From bd507c7cef0d90ce480caf8fccc35b5868afa229 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 15 Aug 2008 13:07:07 +0000 Subject: 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. --- usr.sbin/watch/watch.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'usr.sbin') 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); } -- cgit v1.1