chiark / gitweb /
[PATCH] do not remove real .udev.tdb during RPM build
[elogind.git] / namedev.c
index cd38f25cb0979541ad42e119734b2fdb61abaa35..2f9d8f5f67b08892b55b86903a82edbd8ac00e22 100644 (file)
--- a/namedev.c
+++ b/namedev.c
 #include <sys/wait.h>
 #include <sys/stat.h>
 
+#include "libsysfs/sysfs/libsysfs.h"
 #include "list.h"
 #include "udev.h"
 #include "udev_version.h"
 #include "logging.h"
 #include "namedev.h"
-#include "libsysfs/libsysfs.h"
 #include "klibc_fixups.h"
 
 static struct sysfs_attribute *find_sysfs_attribute(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, char *attr);
@@ -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) {