Date: Sun, 22 Jun 2008 19:26:18 GMT From: Mateusz Guzik <mjguzik@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/124881: [devfs.rules][patch][request] Add possibility to check which ruleset is assigned to specified mount-point Message-ID: <200806221926.m5MJQIMC019203@www.freebsd.org> Resent-Message-ID: <200806221930.m5MJU0kR058344@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 124881 >Category: kern >Synopsis: [devfs.rules][patch][request] Add possibility to check which ruleset is assigned to specified mount-point >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Jun 22 19:30:00 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Mateusz Guzik >Release: 8.0-CURRENT >Organization: >Environment: FreeBSD eternal 8.0-CURRENT FreeBSD 8.0-CURRENT #11: Sun Jun 22 20:56:53 CEST 2008 f@eternal:/usr/obj/usr/src/sys/ETERNAL i386 >Description: Manual page devd(8) does not mention how one can check which ruleset is assigned to specified mount-point and after reading sources I still couldn't find any way to do it. >How-To-Repeat: >Fix: Proposed patch adds support for `rule showset' to devfs. Example usage: [21:07] eternal:~ # devfs rule showset 0 [21:07] eternal:~ # devfs ruleset 10 [21:07] eternal:~ # devfs rule showset 10 Patch attached with submission follows: --- sys/fs/devfs/devfs.h.orig 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.orig 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.orig 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.orig 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 >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806221926.m5MJQIMC019203>