From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kevin P. Fleming" Date: Sat, 08 May 2004 13:38:41 +0000 Subject: [PATCH] allow udev to process all symlink rules for a device Message-Id: <409CE2E1.5000801@backtobasicsmgmt.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------050600030903030803050605" List-Id: To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------050600030903030803050605 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit This patch changes udev's behavior to scan all rules for every device. Only the first NAME rule is accepted, but all SYMLINK rules are accepted. This means that SYMLINK rules can be added in any position to a udev.rules file (or in the rules.d directory) without concern for where they are in relation to the NAME rule for the same device. --------------050600030903030803050605 Content-Type: text/plain; name="udev-025-symlinks.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="udev-025-symlinks.patch" --- udev-orig/namedev.c Wed Apr 21 14:39:10 2004 +++ udev-025/namedev.c Sat May 8 06:33:04 2004 @@ -780,6 +780,7 @@ struct perm_device *perm; struct sysinfo info; char *pos; + int name_rule_found = 0; udev->mode = 0; @@ -805,7 +806,9 @@ strfieldcpy(udev->kernel_number, pos); dbg("kernel_number='%s'", udev->kernel_number); - /* look for a matching rule to apply */ + /* look for matching rules to apply */ + /* only the first matching NAME rule will be used */ + /* all matching SYMLINK rules will be used */ list_for_each_entry(dev, &config_device_list, node) { dbg("process rule"); if (match_rule(dev, class_dev, udev, sysfs_device) == 0) { @@ -827,6 +830,9 @@ strfieldcat(udev->symlink, temp); } + if (name_rule_found) + continue; + if (dev->name[0] != '\0') { /* apply all_partitions flag only at a main block device */ if (dev->partitions > 0 && @@ -836,18 +842,20 @@ info("configured rule in '%s' at line %i applied, '%s' becomes '%s'", dev->config_file, dev->config_line, udev->kernel_name, dev->name); strfieldcpy(udev->name, dev->name); - goto found; + name_rule_found = 1; } } } - /* no rule was found so we use the kernel name */ - strfieldcpy(udev->name, udev->kernel_name); - if (udev->type == 'n') - goto done; - else - goto perms; -found: + if (!name_rule_found) { + /* no NAME rule was found so we use the kernel name */ + strfieldcpy(udev->name, udev->kernel_name); + if (udev->type == 'n') + goto done; + else + goto perms; + } + apply_format(udev, udev->name, sizeof(udev->name), class_dev, sysfs_device); strfieldcpy(udev->config_file, dev->config_file); udev->config_line = dev->config_line; --------------050600030903030803050605-- ------------------------------------------------------- This SF.Net email is sponsored by Sleepycat Software Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to deliver higher performing products faster, at low TCO. http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3 _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel