diff options
author | dd <dd@FreeBSD.org> | 2001-04-17 20:53:11 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2001-04-17 20:53:11 +0000 |
commit | c50aedd1ac88a75ef606d02791936bbe0a1c1ef8 (patch) | |
tree | d883a5884b67a2819ccb71d3781e1e2ea037ba24 /sys | |
parent | 2c4a6563512eff96498548fcd5def21769e27f4a (diff) | |
download | FreeBSD-src-c50aedd1ac88a75ef606d02791936bbe0a1c1ef8.zip FreeBSD-src-c50aedd1ac88a75ef606d02791936bbe0a1c1ef8.tar.gz |
Make this driver play ball with devfs(5).
Reviewed by: brian
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/snp/snp.c | 22 | ||||
-rw-r--r-- | sys/kern/tty_snoop.c | 22 |
2 files changed, 38 insertions, 6 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 442eafd..8560928 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -287,10 +287,10 @@ snpopen(dev, flag, mode, p) return (error); if (dev->si_drv1 == NULL) { - int mynor = minor(dev); - + if (!(dev->si_flags & SI_NAMED)) + make_dev(&snp_cdevsw, minor(dev), UID_ROOT, GID_WHEEL, + 0600, "snp%d", dev2unit(dev)); dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK|M_ZERO); - make_dev(&snp_cdevsw, mynor, 0, 0, 0600, "snp%d", mynor); } else return (EBUSY); @@ -365,6 +365,7 @@ snpclose(dev, flags, fmt, p) free(snp->snp_buf, M_SNP); snp->snp_flags &= ~SNOOP_OPEN; dev->si_drv1 = NULL; + destroy_dev(dev); return (snp_detach(snp)); } @@ -505,10 +506,25 @@ snppoll(dev, events, p) static void snp_drvinit __P((void *unused)); static void +snp_clone(void *arg, char *name, int namelen, dev_t *dev) +{ + int u; + + if (*dev != NODEV) + return; + if (dev_stdclone(name, NULL, "snp", &u) != 1) + return; + *dev = make_dev(&snp_cdevsw, unit2minor(u), UID_ROOT, GID_WHEEL, 0600, + "snp%d", u); + return; +} + +static void snp_drvinit(unused) void *unused; { + EVENTHANDLER_REGISTER(dev_clone, snp_clone, 0, 1000); cdevsw_add(&snp_cdevsw); } diff --git a/sys/kern/tty_snoop.c b/sys/kern/tty_snoop.c index 442eafd..8560928 100644 --- a/sys/kern/tty_snoop.c +++ b/sys/kern/tty_snoop.c @@ -287,10 +287,10 @@ snpopen(dev, flag, mode, p) return (error); if (dev->si_drv1 == NULL) { - int mynor = minor(dev); - + if (!(dev->si_flags & SI_NAMED)) + make_dev(&snp_cdevsw, minor(dev), UID_ROOT, GID_WHEEL, + 0600, "snp%d", dev2unit(dev)); dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK|M_ZERO); - make_dev(&snp_cdevsw, mynor, 0, 0, 0600, "snp%d", mynor); } else return (EBUSY); @@ -365,6 +365,7 @@ snpclose(dev, flags, fmt, p) free(snp->snp_buf, M_SNP); snp->snp_flags &= ~SNOOP_OPEN; dev->si_drv1 = NULL; + destroy_dev(dev); return (snp_detach(snp)); } @@ -505,10 +506,25 @@ snppoll(dev, events, p) static void snp_drvinit __P((void *unused)); static void +snp_clone(void *arg, char *name, int namelen, dev_t *dev) +{ + int u; + + if (*dev != NODEV) + return; + if (dev_stdclone(name, NULL, "snp", &u) != 1) + return; + *dev = make_dev(&snp_cdevsw, unit2minor(u), UID_ROOT, GID_WHEEL, 0600, + "snp%d", u); + return; +} + +static void snp_drvinit(unused) void *unused; { + EVENTHANDLER_REGISTER(dev_clone, snp_clone, 0, 1000); cdevsw_add(&snp_cdevsw); } |