From ea57f51819a358a6c1309cf028a1a2dcd90dd7a5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 May 2012 11:39:57 +0200 Subject: mdev: when found, print major,minor into mdev.log Signed-off-by: Denys Vlasenko --- examples/mdev.conf | 10 ++++++++-- examples/mdev_fat.conf | 8 ++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/mdev.conf b/examples/mdev.conf index cdbb4fcfe..51795694d 100644 --- a/examples/mdev.conf +++ b/examples/mdev.conf @@ -7,8 +7,14 @@ # instead of the default 0:0 660. # # Syntax: -# %s %d:%d %s -# devicename_regex user:group mode +# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# +# [-]: do not stop on this match, continue reading mdev.conf +# =: move, >: move and create a symlink +# !: do not create device node +# @|$|*: run@cmd if $ACTION=add, $cmd if $ACTION=remove, *cmd in all cases null 0:0 666 zero 0:0 666 diff --git a/examples/mdev_fat.conf b/examples/mdev_fat.conf index df329b4b5..d67912ba1 100644 --- a/examples/mdev_fat.conf +++ b/examples/mdev_fat.conf @@ -7,10 +7,14 @@ # instead of the default 0:0 660. # # Syntax: -# [-]devicename_regex user:group mode [>|=path] [@|$|*cmd args...] +# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] +# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...] # +# [-]: do not stop on this match, continue reading mdev.conf # =: move, >: move and create a symlink -# @|$|*: run $cmd on delete, @cmd on create, *cmd on both +# !: do not create device node +# @|$|*: run cmd if $ACTION=remove, @cmd if $ACTION=add, *cmd in all cases # support module loading on hotplug $MODALIAS=.* root:root 660 @modprobe "$MODALIAS" -- cgit v1.2.3 From b6beada5a1432645090b441531b5909983cfbf10 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 18 May 2012 15:11:16 +0200 Subject: mdev: remove undocumented subsystem/devname matching hack It was colliding with matching of devnames with slashes. We need a more generic way to examine env.vars in rules anyway. Signed-off-by: Denys Vlasenko --- examples/mdev_fat.conf | 1 - util-linux/mdev.c | 31 ++----------------------------- 2 files changed, 2 insertions(+), 30 deletions(-) (limited to 'examples') diff --git a/examples/mdev_fat.conf b/examples/mdev_fat.conf index d67912ba1..ceba3a797 100644 --- a/examples/mdev_fat.conf +++ b/examples/mdev_fat.conf @@ -53,7 +53,6 @@ sr[0-9]* root:cdrom 660 @ln -sf $MDEV cdrom fd[0-9]* root:floppy 660 # net devices --net/.* root:root 600 @nameif tun[0-9]* root:root 600 =net/ tap[0-9]* root:root 600 =net/ diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 101acb78a..6603a7d79 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -236,7 +236,6 @@ enum { OP_add, OP_remove }; struct rule { bool keep_matching; bool regex_compiled; - bool regex_has_slash; mode_t mode; int maj, min0, min1; struct bb_uidgid_t ugid; @@ -340,7 +339,6 @@ static void parse_next_rule(void) } xregcomp(&G.cur_rule.match, val, REG_EXTENDED); G.cur_rule.regex_compiled = 1; - G.cur_rule.regex_has_slash = (strchr(val, '/') != NULL); } /* 2nd field: uid:gid - device ownership */ @@ -467,7 +465,6 @@ static char *build_alias(char *alias, const char *device_name) */ static void make_device(char *device_name, char *path, int operation) { - char *subsystem_slash_devname; int major, minor, type, len; if (G.verbose) @@ -511,24 +508,6 @@ static void make_device(char *device_name, char *path, int operation) if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0)) type = S_IFBLK; - /* Make path point to "subsystem/device_name" */ - subsystem_slash_devname = NULL; - /* Check for coldplug invocations first */ - if (strncmp(path, "/sys/block/", 11) == 0) /* legacy case */ - path += sizeof("/sys/") - 1; - else if (strncmp(path, "/sys/class/", 11) == 0) - path += sizeof("/sys/class/") - 1; - else { - /* Example of a hotplug invocation: - * SUBSYSTEM="block" - * DEVPATH="/sys" + "/devices/virtual/mtd/mtd3/mtdblock3" - * ("/sys" is added by mdev_main) - * - path does not contain subsystem - */ - subsystem_slash_devname = concat_path_file(G.subsystem, device_name); - path = subsystem_slash_devname; - } - #if ENABLE_FEATURE_MDEV_CONF G.rule_idx = 0; /* restart from the beginning (think mdev -s) */ #endif @@ -541,7 +520,7 @@ static void make_device(char *device_name, char *path, int operation) char *node_name; const struct rule *rule; - str_to_match = ""; + str_to_match = device_name; rule = next_rule(); @@ -559,12 +538,8 @@ static void make_device(char *device_name, char *path, int operation) dbg("getenv('%s'):'%s'", rule->envvar, str_to_match); if (!str_to_match) continue; - } else { -//TODO: $DEVNAME can have slashes too, -// we should stop abusing '/' as a special syntax in our regex'es - /* regex to match [subsystem/]device_name */ - str_to_match = (rule->regex_has_slash ? path : device_name); } + /* else: str_to_match = device_name */ if (rule->regex_compiled) { int regex_match = regexec(&rule->match, str_to_match, ARRAY_SIZE(off), off, 0); @@ -727,8 +702,6 @@ static void make_device(char *device_name, char *path, int operation) if (!ENABLE_FEATURE_MDEV_CONF || !rule->keep_matching) break; } /* for (;;) */ - - free(subsystem_slash_devname); } /* File callback for /sys/ traversal */ -- cgit v1.2.3