chiark / gitweb /
[PATCH] udev build tweaks to tdb's spinlock code
[elogind.git] / udev-add.c
index 7906638a7f066670fbd2bea6d5a603d523fdb309..8c63214a46794ebb233ed1e8cffc8c8875865697 100644 (file)
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <sys/stat.h>
 
 #include "udev.h"
 #include "udev_version.h"
@@ -34,8 +35,6 @@
 #include "udevdb.h"
 #include "libsysfs/libsysfs.h"
 
-static char sysfs_path[SYSFS_PATH_MAX];
-
 /* 
  * Right now the major/minor of a device is stored in a file called
  * "dev" in sysfs.
@@ -75,7 +74,7 @@ static int create_node(struct udevice *dev)
        char filename[255];
        int retval = 0;
 
-       strncpy(filename, UDEV_ROOT, sizeof(filename));
+       strncpy(filename, udev_root, sizeof(filename));
        strncat(filename, dev->name, sizeof(filename));
 
        switch (dev->type) {
@@ -130,7 +129,7 @@ exit:
  * If it doesn't happen in about 10 seconds, give up.
  */
 #define SECONDS_TO_WAIT_FOR_DEV                10
-int sleep_for_dev(char *path)
+static int sleep_for_dev(char *path)
 {
        char filename[SYSFS_PATH_MAX + 6];
        struct stat buf;
@@ -152,6 +151,7 @@ int sleep_for_dev(char *path)
                /* sleep for a second or two to give the kernel a chance to
                 * create the dev file */
                sleep(1);
+               ++loop;
        }
        retval = -ENODEV;
 exit:
@@ -162,7 +162,6 @@ int udev_add_device(char *path, char *subsystem)
 {
        struct sysfs_class_device *class_dev;
        struct udevice dev;
-       struct device_attr attr;
        int retval = -EINVAL;
 
        /* for now, the block layer is the only place where block devices are */
@@ -171,13 +170,6 @@ int udev_add_device(char *path, char *subsystem)
        else
                dev.type = 'c';
 
-       retval = sysfs_get_mnt_path(sysfs_path, SYSFS_PATH_MAX);
-       dbg("sysfs_path = %s", sysfs_path);
-       if (retval) {
-               dbg("sysfs_get_mnt_path failed");
-               goto exit;
-       }
-
        retval = sleep_for_dev(path);
        if (retval)
                goto exit;
@@ -186,7 +178,7 @@ int udev_add_device(char *path, char *subsystem)
        if (class_dev == NULL)
                goto exit;
 
-       retval = namedev_name_device(class_dev, &attr);
+       retval = namedev_name_device(class_dev, &dev);
        if (retval)
                return retval;
 
@@ -196,10 +188,10 @@ int udev_add_device(char *path, char *subsystem)
                goto exit;
        }
 
-       strcpy(dev.name, attr.name);
-       strcpy(dev.owner, attr.owner);
-       strcpy(dev.group, attr.group);
-       dev.mode = attr.mode;
+//     strcpy(dev.name, attr.name);
+//     strcpy(dev.owner, attr.owner);
+//     strcpy(dev.group, attr.group);
+//     dev.mode = attr.mode;
        
        retval = udevdb_add_dev(path, &dev);
        if (retval != 0)