--- sys/fs/devfs/devfs.h 2008-06-22 14:09:46.000000000 +0200 +++ sys/fs/devfs/devfs.h 2008-06-22 15:27:46.000000000 +0200 @@ -111,10 +111,11 @@ #define DEVFSIO_RGETNEXT _IOWR('D', 4, struct devfs_rule) #define DEVFSIO_SUSE _IOW('D', 10, devfs_rsnum) #define DEVFSIO_SAPPLY _IOW('D', 11, devfs_rsnum) #define DEVFSIO_SGETNEXT _IOWR('D', 12, devfs_rsnum) +#define DEVFSIO_SGETCURRENT _IOWR('D', 13, devfs_rsnum) /* XXX: DEVFSIO_RS_GET_INFO for refcount, active if any, etc. */ #ifdef _KERNEL --- sys/fs/devfs/devfs_rule.c 2008-03-20 17:08:42.000000000 +0100 +++ sys/fs/devfs/devfs_rule.c 2008-06-22 15:58:30.000000000 +0200 @@ -285,10 +285,13 @@ error = ESRCH; break; } devfs_ruleset_applydm(ds, dm); break; + case DEVFSIO_SGETCURRENT: + *(devfs_rsnum *)data = dm->dm_ruleset; + break; case DEVFSIO_SGETNEXT: rsnum = *(devfs_rsnum *)data; TAILQ_FOREACH(ds, &devfs_rulesets, ds_list) { if (ds->ds_number > rsnum) break; --- sbin/devfs/rule.c 2008-06-22 15:19:59.000000000 +0200 +++ sbin/devfs/rule.c 2008-06-22 15:20:03.000000000 +0200 @@ -53,19 +53,20 @@ static void rulespec_intok(struct devfs_rule *dr, int ac, char **av, devfs_rsnum rsnum); static void rulespec_outfp(FILE *fp, struct devfs_rule *dr); static command_t rule_add, rule_apply, rule_applyset; -static command_t rule_del, rule_delset, rule_show, rule_showsets; +static command_t rule_del, rule_delset, rule_show, rule_showset, rule_showsets; static ctbl_t ctbl_rule = { { "add", rule_add }, { "apply", rule_apply }, { "applyset", rule_applyset }, { "del", rule_del }, { "delset", rule_delset }, { "show", rule_show }, + { "showset", rule_showset }, { "showsets", rule_showsets }, { NULL, NULL } }; static struct intstr ist_type[] = { @@ -227,10 +228,26 @@ } return (0); } static int +rule_showset(int ac, char **av __unused) +{ + devfs_rsnum rsnum; + + if (ac != 1) + usage(); + + if (ioctl(mpfd, DEVFSIO_SGETCURRENT, &rsnum) != -1) + printf("%d\n", rsnum); + + if (errno != 0) + err(1, "ioctl DEVFSIO_SGETCURRENT"); + return (0); +} + +static int rule_showsets(int ac, char **av __unused) { devfs_rsnum rsnum; if (ac != 1) --- sbin/devfs/devfs.8 2006-12-29 23:45:12.000000000 +0100 +++ sbin/devfs/devfs.8 2008-06-22 15:40:06.000000000 +0200 @@ -132,10 +132,12 @@ Display the rule number .Ar rulenum , or all the rules in the ruleset. The output lines (one line per rule) are expected to be valid .Ar rulespec Ns s . +.It Cm rule showset +Display the number of the ruleset associated with the mount-point. .It Cm rule showsets Report the numbers of existing rulesets. .It Cm ruleset Ar ruleset Set ruleset number .Ar ruleset