chiark / gitweb /
[PATCH] update udev scsi_id to scsi_id 0.5
[elogind.git] / namedev.c
index a3ae1d36b3f9786ca04d6c9abde4e97e8110c310..5e3db1326c13e5a97eb70f2250b4488f65fdc3d1 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -32,9 +32,7 @@
 #include <time.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
-#ifndef __KLIBC__
 #include <sys/sysinfo.h>
-#endif
 
 #include "libsysfs/sysfs/libsysfs.h"
 #include "list.h"
@@ -199,23 +197,21 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
        struct sysfs_attribute *tmpattr;
 
        pos = string;
-
        while (1) {
-               pos = strchr(string, '%');
-               if (pos != NULL) {
-                       pos[0] = '\0';
-                       tail = pos+1;
-                       len = get_format_len(&tail);
-                       c = tail[0];
-                       strfieldcpy(temp, tail+1);
-                       tail = temp;
-               } else {
+               pos = strchr(pos, '%');
+               if (pos == NULL)
                        break;
-               }
-               dbg("format=%c, string='%s', tail='%s'",c , string, tail);
 
+               pos[0] = '\0';
+               tail = pos+1;
+               len = get_format_len(&tail);
+               c = tail[0];
+               strfieldcpy(temp, tail+1);
+               tail = temp;
+               dbg("format=%c, string='%s', tail='%s'",c , string, tail);
                attr = get_format_attribute(&tail);
 
+
                switch (c) {
                case 'b':
                        if (strlen(udev->bus_id) == 0)
@@ -286,6 +282,7 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
                        break;
                case '%':
                        strfieldcatmax(string, "%", maxsize);
+                       pos++;
                        break;
                default:
                        dbg("unknown substitution type '%%%c'", c);
@@ -850,13 +847,13 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud
 
 found:
        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;
 
        if (udev->type == 'n')
                goto done;
 
        udev->partitions = dev->partitions;
-       strfieldcpy(udev->config_file, dev->config_file);
-       udev->config_line = dev->config_line;
 
        /* get permissions given in rule */
        set_empty_perms(udev, dev->mode,