chiark / gitweb /
replace spaces in dm and md name symlinks
authorKay Sievers <kay.sievers@vrfy.org>
Mon, 6 Oct 2008 22:41:00 +0000 (00:41 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Mon, 6 Oct 2008 22:41:00 +0000 (00:41 +0200)
We create multiple symlinks for dm names with spaces, which
isn't what we want.

rules/packages/64-md-raid.rules
rules/suse/64-device-mapper.rules
udev/udev_rules.c

index 02a321093a3d162f52e134952ae5d350721d3da1..0e6a939c123e07ed21a53ca1bc9a0a61a55634e6 100644 (file)
@@ -11,9 +11,9 @@ KERNEL!="md*", GOTO="md_end"
 ATTR{md/array_state}=="|clear|inactive", GOTO="md_end"
 
 IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
-ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}"
+ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace"
 ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}"
-ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n"
+ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace"
 ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n"
 
 IMPORT{program}="vol_id --export $tempnode"
index b065aec55417fd24fb2a164be4a4bbdefbf7a9b6..e0a63eee727e879ea0ee855322e5b6754c9273da 100644 (file)
@@ -8,7 +8,7 @@ ACTION!="add|change", GOTO="device_mapper_end"
 IMPORT{program}="/sbin/dmsetup export -j%M -m%m"
 ENV{DM_NAME}!="?*", GOTO="device_mapper_end"
 
-SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
+SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}", OPTIONS+="string_escape=replace"
 ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
 
 ENV{DM_STATE}=="SUSPENDED", GOTO="device_mapper_end"
index 9527f46e7948b11dd4ed59072f499ed5a1afd066..d06f536d1e0e24aa518ffe656d5d23289cacca4e 100644 (file)
@@ -1447,7 +1447,7 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice)
                             rule->symlink.operation == KEY_OP_ADD)) {
                                char temp[UTIL_PATH_SIZE];
                                char *pos, *next;
-                               int count;
+                               int count = 0;
 
                                if (rule->symlink.operation == KEY_OP_ASSIGN_FINAL)
                                        udevice->symlink_final = 1;
@@ -1459,12 +1459,12 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udevice)
                                /* allow  multiple symlinks separated by spaces */
                                util_strlcpy(temp, key_val(rule, &rule->symlink), sizeof(temp));
                                udev_rules_apply_format(udevice, temp, sizeof(temp));
-                               if (rule->string_escape == ESCAPE_UNSET ||
-                                   rule->string_escape == ESCAPE_REPLACE) {
+                               if (rule->string_escape == ESCAPE_UNSET)
                                        count = util_replace_chars(temp, ALLOWED_CHARS_FILE " ");
-                                       if (count > 0)
-                                               info(udevice->udev, "%i character(s) replaced\n" , count);
-                               }
+                               else if (rule->string_escape == ESCAPE_REPLACE)
+                                       count = util_replace_chars(temp, ALLOWED_CHARS_FILE);
+                               if (count > 0)
+                                       info(udevice->udev, "%i character(s) replaced\n" , count);
                                dbg(udevice->udev, "rule applied, added symlink(s) '%s'\n", temp);
                                pos = temp;
                                while (isspace(pos[0]))