Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 98169 - udev adds empty symlinks
Summary: udev adds empty symlinks
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Greg Kroah-Hartman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-06 18:08 UTC by Georgi Georgiev
Modified: 2005-07-07 16:08 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Georgi Georgiev 2005-07-06 18:08:05 UTC
Here is the, I am guessing cosmetic, problem:

chutz@lion ~ $ udevinfo -q all -n /dev/cdroms/nec
P: /block/hdd
N: hdd
S: cdroms/nec
S: 
S: cdrom
S: cdrw
S: dvd
S: dvdrw
chutz@lion ~ $ udevinfo -q all -n /dev/cdroms/pioneer
P: /block/sr0
N: sr0
S: cdroms/pioneer
S: 
S: cdrom1
S: dvd1
chutz@lion ~ $ udevinfo -q all -n /dev/cdroms/plextor
P: /block/sr1
N: sr1
S: cdroms/plextor
S: 
S: cdrom2
S: cdrw1

Steps to reproduce:

1. add a rule for your udev to find
BUS=="ide", KERNEL=="hd[a-z]", PROGRAM="/etc/udev/scripts/cdsymlinks.sh %k", SYMLINK+="%c{1] %c{2] %c{3} %c{4} %c{5} %c{6}"

2. attach an IDE cd-rom (for simplicity)
3. run udevstart
4. udevinfo -q all -n /dev/cdrom

The problem is that:

- cdsymlinks.sh outputs every symlink prefixed with a space.
- udev_rules.c assumes that the initial space is a delimiter and adds an empty symlink
- udev_rules.c would also fail if its parameters are delimited with multiple spaces or if there is a trailing space

This is how I solved the problem for now:

--- udev-061/udev_utils.c       2005-07-07 10:01:21.000000000 +0900
+++ udev-061/udev_utils.c.new   2005-07-07 10:01:16.000000000 +0900
@@ -302,6 +302,7 @@ int name_list_add(struct list_head *name
        struct name_entry *loop_name;
        struct name_entry *new_name;
 
+       if (strlen(name) == 0) return 0;
        list_for_each_entry(loop_name, name_list, node) {
                /* avoid doubles */
                if (strcmp(loop_name->name, name) == 0) {

Tested and working.

I was not sure if name_list_add should refuse empty parameters, or if the parser should be smarter, so I went for the one that introduces less changes.

This also made me think. Does the default rule have to be "%c{1} %c{2} %c{3}..." when "%c" does the same job and is also future proof (for when there are 50 links output by the script)?
Comment 1 Georgi Georgiev 2005-07-06 18:08:30 UTC
changing the subject : rules -> symlinks
Comment 2 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-07-07 14:09:34 UTC
Yes, %c would be better.

I'll look into checking in your patch too, many thanks.
Comment 3 Greg Kroah-Hartman (RETIRED) gentoo-dev 2005-07-07 16:08:01 UTC
Fixed in 062 release