linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] allow udev to process all symlink rules for a device
@ 2004-05-08 13:38 Kevin P. Fleming
  2004-05-20 18:18 ` Greg KH
  2004-05-20 18:44 ` Kevin P. Fleming
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin P. Fleming @ 2004-05-08 13:38 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

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.

[-- Attachment #2: udev-025-symlinks.patch --]
[-- Type: text/plain, Size: 1725 bytes --]

--- 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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] allow udev to process all symlink rules for a device
  2004-05-08 13:38 [PATCH] allow udev to process all symlink rules for a device Kevin P. Fleming
@ 2004-05-20 18:18 ` Greg KH
  2004-05-20 18:44 ` Kevin P. Fleming
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2004-05-20 18:18 UTC (permalink / raw)
  To: linux-hotplug

On Sat, May 08, 2004 at 06:38:41AM -0700, Kevin P. Fleming wrote:
> 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.

I like the idea, unfortunatly your patch breaks a number of the
regression tests.  Can you try fixing it so that the udev-test.pl script
in the test directory does not fail?

thanks,

greg k-h


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_idÅ66&op=click
_______________________________________________
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] allow udev to process all symlink rules for a device
  2004-05-08 13:38 [PATCH] allow udev to process all symlink rules for a device Kevin P. Fleming
  2004-05-20 18:18 ` Greg KH
@ 2004-05-20 18:44 ` Kevin P. Fleming
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin P. Fleming @ 2004-05-20 18:44 UTC (permalink / raw)
  To: linux-hotplug

Greg KH wrote:

> I like the idea, unfortunatly your patch breaks a number of the
> regression tests.  Can you try fixing it so that the udev-test.pl script
> in the test directory does not fail?

I will make the attempt :-)


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_idÅ66&op=click
_______________________________________________
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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-20 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-08 13:38 [PATCH] allow udev to process all symlink rules for a device Kevin P. Fleming
2004-05-20 18:18 ` Greg KH
2004-05-20 18:44 ` Kevin P. Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).