aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-05-18 15:11:16 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2012-05-18 15:11:16 +0200
commitb6beada5a1432645090b441531b5909983cfbf10 (patch)
treee0ff1a00e156a366fbe590259f948988b995eb5c
parentea57f51819a358a6c1309cf028a1a2dcd90dd7a5 (diff)
downloadbusybox-w32-b6beada5a1432645090b441531b5909983cfbf10.tar.gz
busybox-w32-b6beada5a1432645090b441531b5909983cfbf10.tar.bz2
busybox-w32-b6beada5a1432645090b441531b5909983cfbf10.zip
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 <vda.linux@googlemail.com>
-rw-r--r--examples/mdev_fat.conf1
-rw-r--r--util-linux/mdev.c31
2 files changed, 2 insertions, 30 deletions
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
53fd[0-9]* root:floppy 660 53fd[0-9]* root:floppy 660
54 54
55# net devices 55# net devices
56-net/.* root:root 600 @nameif
57tun[0-9]* root:root 600 =net/ 56tun[0-9]* root:root 600 =net/
58tap[0-9]* root:root 600 =net/ 57tap[0-9]* root:root 600 =net/
59 58
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 };
236struct rule { 236struct rule {
237 bool keep_matching; 237 bool keep_matching;
238 bool regex_compiled; 238 bool regex_compiled;
239 bool regex_has_slash;
240 mode_t mode; 239 mode_t mode;
241 int maj, min0, min1; 240 int maj, min0, min1;
242 struct bb_uidgid_t ugid; 241 struct bb_uidgid_t ugid;
@@ -340,7 +339,6 @@ static void parse_next_rule(void)
340 } 339 }
341 xregcomp(&G.cur_rule.match, val, REG_EXTENDED); 340 xregcomp(&G.cur_rule.match, val, REG_EXTENDED);
342 G.cur_rule.regex_compiled = 1; 341 G.cur_rule.regex_compiled = 1;
343 G.cur_rule.regex_has_slash = (strchr(val, '/') != NULL);
344 } 342 }
345 343
346 /* 2nd field: uid:gid - device ownership */ 344 /* 2nd field: uid:gid - device ownership */
@@ -467,7 +465,6 @@ static char *build_alias(char *alias, const char *device_name)
467 */ 465 */
468static void make_device(char *device_name, char *path, int operation) 466static void make_device(char *device_name, char *path, int operation)
469{ 467{
470 char *subsystem_slash_devname;
471 int major, minor, type, len; 468 int major, minor, type, len;
472 469
473 if (G.verbose) 470 if (G.verbose)
@@ -511,24 +508,6 @@ static void make_device(char *device_name, char *path, int operation)
511 if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0)) 508 if (strstr(path, "/block/") || (G.subsystem && strncmp(G.subsystem, "block", 5) == 0))
512 type = S_IFBLK; 509 type = S_IFBLK;
513 510
514 /* Make path point to "subsystem/device_name" */
515 subsystem_slash_devname = NULL;
516 /* Check for coldplug invocations first */
517 if (strncmp(path, "/sys/block/", 11) == 0) /* legacy case */
518 path += sizeof("/sys/") - 1;
519 else if (strncmp(path, "/sys/class/", 11) == 0)
520 path += sizeof("/sys/class/") - 1;
521 else {
522 /* Example of a hotplug invocation:
523 * SUBSYSTEM="block"
524 * DEVPATH="/sys" + "/devices/virtual/mtd/mtd3/mtdblock3"
525 * ("/sys" is added by mdev_main)
526 * - path does not contain subsystem
527 */
528 subsystem_slash_devname = concat_path_file(G.subsystem, device_name);
529 path = subsystem_slash_devname;
530 }
531
532#if ENABLE_FEATURE_MDEV_CONF 511#if ENABLE_FEATURE_MDEV_CONF
533 G.rule_idx = 0; /* restart from the beginning (think mdev -s) */ 512 G.rule_idx = 0; /* restart from the beginning (think mdev -s) */
534#endif 513#endif
@@ -541,7 +520,7 @@ static void make_device(char *device_name, char *path, int operation)
541 char *node_name; 520 char *node_name;
542 const struct rule *rule; 521 const struct rule *rule;
543 522
544 str_to_match = ""; 523 str_to_match = device_name;
545 524
546 rule = next_rule(); 525 rule = next_rule();
547 526
@@ -559,12 +538,8 @@ static void make_device(char *device_name, char *path, int operation)
559 dbg("getenv('%s'):'%s'", rule->envvar, str_to_match); 538 dbg("getenv('%s'):'%s'", rule->envvar, str_to_match);
560 if (!str_to_match) 539 if (!str_to_match)
561 continue; 540 continue;
562 } else {
563//TODO: $DEVNAME can have slashes too,
564// we should stop abusing '/' as a special syntax in our regex'es
565 /* regex to match [subsystem/]device_name */
566 str_to_match = (rule->regex_has_slash ? path : device_name);
567 } 541 }
542 /* else: str_to_match = device_name */
568 543
569 if (rule->regex_compiled) { 544 if (rule->regex_compiled) {
570 int regex_match = regexec(&rule->match, str_to_match, ARRAY_SIZE(off), off, 0); 545 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)
727 if (!ENABLE_FEATURE_MDEV_CONF || !rule->keep_matching) 702 if (!ENABLE_FEATURE_MDEV_CONF || !rule->keep_matching)
728 break; 703 break;
729 } /* for (;;) */ 704 } /* for (;;) */
730
731 free(subsystem_slash_devname);
732} 705}
733 706
734/* File callback for /sys/ traversal */ 707/* File callback for /sys/ traversal */