X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev-add.c;h=8c63214a46794ebb233ed1e8cffc8c8875865697;hb=1c386a909af69bc5b53eb03fedead725f5fc8331;hp=7906638a7f066670fbd2bea6d5a603d523fdb309;hpb=5840bc63e2029d22682d8de77dc8fcc4da1b436c;p=elogind.git diff --git a/udev-add.c b/udev-add.c index 7906638a7..8c63214a4 100644 --- a/udev-add.c +++ b/udev-add.c @@ -27,6 +27,7 @@ #include #include #include +#include #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)