aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/watch
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2008-08-15 13:07:07 +0000
committerEd Schouten <ed@FreeBSD.org>2008-08-15 13:07:07 +0000
commit2e37c8eacb89146024f974f3391fea61d9ee1ea5 (patch)
tree97fa442f4619eff0b084537b42202b5555ff9c24 /usr.sbin/watch
parent854d77bdd657e1331f1fec1e9394bcb3f7afcab5 (diff)
downloadsrc-2e37c8eacb89146024f974f3391fea61d9ee1ea5.tar.gz
src-2e37c8eacb89146024f974f3391fea61d9ee1ea5.zip
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.
Notes
Notes: svn path=/head/; revision=181755
Diffstat (limited to 'usr.sbin/watch')
-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 cc833ef38fd8..388614e08c18 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);
}