Index: share/man/man5/devfs.5 =================================================================== --- share/man/man5/devfs.5 (revision 231065) +++ share/man/man5/devfs.5 (working copy) @@ -90,6 +90,29 @@ and .Pa 2 . .Xr fdescfs 5 creates files for all open descriptors. +.Pp +The options are as follows: +.Bl -tag -width indent +.It Fl o Ar options +Use the specified mount +.Ar options , +as described in +.Xr mount 8 . +The following devfs file system-specific options are available: +.Bl -tag -width indent +.It Cm ruleset Ns No = Ns Ar ruleset +Set ruleset number +.Ar ruleset +as the current ruleset for the mount-point and apply all its rules. If the +ruleset number +.Ar ruleset +does not exist, an empty ruleset with the number +.Ar ruleset +is created. See +.Xr devfs 8 +for more information on working with devfs rulesets. +.El +.El .Sh FILES .Bl -tag -width /dev/XXXX -compact .It Pa /dev Index: sys/fs/devfs/devfs_rule.c =================================================================== --- sys/fs/devfs/devfs_rule.c (revision 231065) +++ sys/fs/devfs/devfs_rule.c (working copy) @@ -771,3 +771,17 @@ devfs_rules_cleanup(struct devfs_mount *dm) devfs_ruleset_reap(ds); } } + +/* + * Make rsnum the active ruleset for dm (locked) + */ +void +devfs_ruleset_set(devfs_rsnum rsnum, struct devfs_mount *dm) +{ + + sx_assert(&dm->dm_lock, SX_XLOCKED); + + sx_xlock(&sx_rules); + devfs_ruleset_use(rsnum, dm); + sx_xunlock(&sx_rules); +} Index: sys/fs/devfs/devfs_vfsops.c =================================================================== --- sys/fs/devfs/devfs_vfsops.c (revision 231065) +++ sys/fs/devfs/devfs_vfsops.c (working copy) @@ -65,6 +65,7 @@ devfs_mount(struct mount *mp) int error; struct devfs_mount *fmp; struct vnode *rvp; + devfs_rsnum rsnum; if (devfs_unr == NULL) devfs_unr = new_unrhdr(0, INT_MAX, NULL); @@ -74,6 +75,18 @@ devfs_mount(struct mount *mp) if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS)) return (EOPNOTSUPP); + rsnum = 0; + + if (mp->mnt_optnew != NULL && + vfs_getopt(mp->mnt_optnew, "ruleset", NULL, NULL) == 0) { + if (vfs_scanopt(mp->mnt_optnew, "ruleset", "%d", + &rsnum) != 1) { + vfs_mount_error(mp, "%s", + "invalid ruleset specification"); + return (EINVAL); + } + } + fmp = malloc(sizeof *fmp, M_DEVFS, M_WAITOK | M_ZERO); fmp->dm_idx = alloc_unr(devfs_unr); sx_init(&fmp->dm_lock, "devfsmount"); @@ -101,6 +114,12 @@ devfs_mount(struct mount *mp) return (error); } + if (rsnum != 0) { + sx_xlock(&fmp->dm_lock); + devfs_ruleset_set(rsnum, fmp); + sx_xunlock(&fmp->dm_lock); + } + VOP_UNLOCK(rvp, 0); vfs_mountedfrom(mp, "devfs"); Index: sys/fs/devfs/devfs.h =================================================================== --- sys/fs/devfs/devfs.h (revision 231065) +++ sys/fs/devfs/devfs.h (working copy) @@ -182,6 +182,7 @@ void devfs_rules_apply(struct devfs_mount *, struc void devfs_rules_cleanup(struct devfs_mount *); int devfs_rules_ioctl(struct devfs_mount *, u_long, caddr_t, struct thread *); +void devfs_ruleset_set(devfs_rsnum rsnum, struct devfs_mount *dm); int devfs_allocv(struct devfs_dirent *, struct mount *, int, struct vnode **); char *devfs_fqpn(char *, struct devfs_mount *, struct devfs_dirent *,