chiark / gitweb /
[PATCH] mv libsysfs/libsysfs.h to libsysfs/sysfs/libsysfs.h to make it easier to...
[elogind.git] / namedev.c
index cd38f25cb0979541ad42e119734b2fdb61abaa35..90c85d41e4d8571926bae2233adc8559cfa3c919 100644 (file)
--- a/namedev.c
+++ b/namedev.c
@@ -219,6 +219,7 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys
        char *pos3;
        char *attr;
        int num;
+       int i;
        char c;
        struct sysfs_attribute *tmpattr;
 
@@ -270,11 +271,15 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys
                case 'c':
                        if (strlen(udev->program_result) == 0)
                                break;
-                       if (num > 0) {
+                       /* get part part of the result string */
+                       i = num; /* num syntax is deprecated and will be removed  */
+                       if (attr != NULL)
+                               i = atoi(attr);
+                       if (i > 0) {
                                strncpy(temp1, udev->program_result, sizeof(temp1));
                                pos2 = temp1;
-                               while (num) {
-                                       num--;
+                               while (i) {
+                                       i--;
                                        pos3 = strsep(&pos2, " ");
                                        if (pos3 == NULL) {
                                                dbg("requested part of result string not found");
@@ -618,7 +623,8 @@ static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_de
        tspec.tv_nsec = 10000000;  /* sleep 10 millisec */
        loop = 10;
        while (loop--) {
-               nanosleep(&tspec, NULL);
+               if (udev_sleep)
+                       nanosleep(&tspec, NULL);
                if (class_dev_parent)
                        sysfs_device = sysfs_get_classdev_device(class_dev_parent);
                else
@@ -645,7 +651,8 @@ device_found:
                loop = 10;
                tspec.tv_nsec = 10000000;
                while (loop--) {
-                       nanosleep(&tspec, NULL);
+                       if (udev_sleep)
+                               nanosleep(&tspec, NULL);
                        sysfs_get_device_bus(sysfs_device);
                        
                        if (sysfs_device->bus[0] != '\0')
@@ -820,7 +827,7 @@ found:
        /* substitute placeholder */
        apply_format(udev, udev->name, class_dev, sysfs_device);
        apply_format(udev, udev->symlink, class_dev, sysfs_device);
-
+       udev->partitions = dev->partitions;
 done:
        perm = find_perm(udev->name);
        if (perm) {