Skip to contentSkip to conversation

: fix multiple symlinks (was: Re: udev-021 mdk RPM)

PATCH In review Andrey Borzenkov 2 participants 2 messages Mar 14, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : fix multiple symlinks (was: Re: udev-021 mdk RPM)

Quoted 12 lines · Svetoslav Slavtchev
Quoted 7 lines · Svetoslav Slavtchev
Quoted 6 lines
Quoted 1 line

Svetloslav, are you still interested?

yep .-)
i actually was working on a bk snapshot from 2-3 days ago but now that 022 is out, i'll update it and upload to
http://karlovo.demon.co.uk/~svetlio/cook/2.6/udev/

so the bk snapshot works
and the final 022 creates a lot of "*/%n"" , "%c{1}", "%k" devices :(

This got completely broken.

Kay, you cannot apply_format after loop over rules was exited. At this point information is long ago lost. Format is per-rule; there is no place to save information for all rules used. You first add symlink that is using results of program invocation _in_the_same_rule_, then those results are lost and finally you apply some random values.

Attached patch fixes it.

-andrey

namedev.c renamed from namedev.c.symlink +10 -2
@@ -814,12 +814,21 @@ int namedev_name_device(struct sysfs_cla
 				return -1;
 			}
 
+			/*
+			 * We must apply format here; we can't do it after
+			 * loop has exited because information will be lost.
+			 * Format is per-rule not global
+			 */
 			if (dev->symlink[0] != '\0') {
+				char temp[NAMESIZE];
+
 				info("configured rule in '%s' at line %i applied, added symlink '%s'",
 				     dev->config_file, dev->config_line, dev->symlink);
+				strfieldcpy(temp, dev->symlink);
+				apply_format(udev, temp, sizeof(temp), class_dev, sysfs_device);
 				if (udev->symlink[0] != '\0')
 					strfieldcat(udev->symlink, " ");
-				strfieldcat(udev->symlink, dev->symlink);
+				strfieldcat(udev->symlink, temp);
 			}
 
 			if (dev->name[0] != '\0') {
@@ -837,7 +846,6 @@ int namedev_name_device(struct sysfs_cla
 
 found:
 	apply_format(udev, udev->name, sizeof(udev->name), class_dev, sysfs_device);
-	apply_format(udev, udev->symlink, sizeof(udev->symlink), class_dev, sysfs_device);
 	udev->partitions = dev->partitions;
 
 done:
#1 lore raw
Quoted 2 lines · Andrey Borzenkov

Kay, you cannot apply_format after loop over rules was exited. At this point information is long ago lost. Format is per-rule; there is no place to save

Right, PROGRAM in a symlink only rule is broken, so we need to do in the loop. I missed that part, sorry.

Thanks,
Kay

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel