diff options
-rw-r--r-- | sys/fs/devfs/devfs_devs.c | 6 | ||||
-rw-r--r-- | sys/kern/kern_conf.c | 24 | ||||
-rw-r--r-- | sys/sys/conf.h | 7 |
3 files changed, 22 insertions, 15 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 7a1647b..761caa5 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -318,9 +318,9 @@ devfs_populate(struct devfs_mount *dm) bcopy(pdev->si_name, de->de_symlink, j); } else { de->de_inode = i; - de->de_uid = dev->si_devsw->d_uid; - de->de_gid = dev->si_devsw->d_gid; - de->de_mode = dev->si_devsw->d_mode; + de->de_uid = dev->si_uid; + de->de_gid = dev->si_gid; + de->de_mode = dev->si_mode; de->de_dirent->d_type = DT_CHR; } #ifdef MAC diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index c7d33ea..e4d44ba 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -68,6 +68,16 @@ dev_unlock(void) } void +dev_ref(struct cdev *dev) +{ + + mtx_assert(&devmtx, MA_NOTOWNED); + mtx_lock(&devmtx); + dev->si_refcount++; + mtx_unlock(&devmtx); +} + +void dev_refl(struct cdev *dev) { @@ -361,7 +371,7 @@ prep_cdevsw(struct cdevsw *devsw) } struct cdev * -make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, const char *fmt, ...) +make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int mode, const char *fmt, ...) { struct cdev *dev; va_list ap; @@ -370,15 +380,8 @@ make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, con KASSERT((minornr & ~MAXMINOR) == 0, ("Invalid minor (0x%x) in make_dev", minornr)); - if (!(devsw->d_flags & D_INIT)) { + if (!(devsw->d_flags & D_INIT)) prep_cdevsw(devsw); - if (devsw->d_uid == 0) - devsw->d_uid = uid; - if (devsw->d_gid == 0) - devsw->d_gid = gid; - if (devsw->d_mode == 0) - devsw->d_mode = perms; - } dev = allocdev(); dev_lock(); dev = newdev(devsw, minornr, dev); @@ -407,6 +410,9 @@ make_dev(struct cdevsw *devsw, int minornr, uid_t uid, gid_t gid, int perms, con dev->si_devsw = devsw; dev->si_flags |= SI_NAMED; + dev->si_uid = uid; + dev->si_gid = gid; + dev->si_mode = mode; devfs_create(dev); dev_unlock(); diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 9b67dce..12cad57 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -65,11 +65,13 @@ struct cdev { struct timespec si_atime; struct timespec si_ctime; struct timespec si_mtime; + uid_t si_uid; + gid_t si_gid; + mode_t si_mode; u_int si_drv0; int si_refcount; LIST_ENTRY(cdev) si_list; LIST_ENTRY(cdev) si_clone; - LIST_ENTRY(cdev) si_hash; /* UNUSED */ LIST_HEAD(,devfs_dirent)si_alist; LIST_HEAD(, cdev) si_children; LIST_ENTRY(cdev) si_siblings; @@ -180,14 +182,12 @@ typedef int dumper_t( * Flags used for internal housekeeping */ #define D_INIT 0x80000000 /* cdevsw initialized */ -#define D_ALLOCMAJ 0x40000000 /* major# is allocated */ /* * Character device switch table */ struct cdevsw { int d_version; - int d_maj; u_int d_flags; const char *d_name; d_open_t *d_open; @@ -247,6 +247,7 @@ struct cdevsw *dev_refthread(struct cdev *_dev); void dev_relthread(struct cdev *_dev); int dev_named(struct cdev *_pdev, const char *_name); void dev_depends(struct cdev *_pdev, struct cdev *_cdev); +void dev_ref(struct cdev *dev); void dev_refl(struct cdev *dev); void dev_rel(struct cdev *dev); void dev_strategy(struct cdev *dev, struct buf *bp); |