X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev-add.c;h=d158c41b1d54adbc138a28d9ea098f1e855c9a95;hp=c8aa2f70c9fe0a540de2b91f4645d39d166111b2;hb=c2405f502cae4a634a25674306cffefb85df9ebb;hpb=a2822451e27dbc576343834e76d5382d5112ac24 diff --git a/udev-add.c b/udev-add.c index c8aa2f70c..d158c41b1 100644 --- a/udev-add.c +++ b/udev-add.c @@ -71,7 +71,7 @@ exit: /* * We also want to add some permissions here, and possibly some symlinks */ -static int create_node(char *name, char type, int major, int minor, int mode) +static int create_node(char *name, char type, int major, int minor, mode_t mode) { char filename[255]; int retval = 0; @@ -93,14 +93,15 @@ static int create_node(char *name, char type, int major, int minor, int mode) return -EINVAL; } - retval = mknod(filename,mode,makedev(major,minor)); + dbg("mknod(%s, %#o, %u, %u)", filename, mode, major, minor); + retval = mknod(filename, mode, makedev(major, minor)); if (retval) dbg("mknod(%s, %#o, %u, %u) failed with error '%s'", filename, mode, major, minor, strerror(errno)); return retval; } -struct sysfs_class_device *get_class_dev(char *device_name) +static struct sysfs_class_device *get_class_dev(char *device_name) { char sysfs_path[SYSFS_PATH_MAX]; char dev_path[SYSFS_PATH_MAX]; @@ -136,7 +137,6 @@ int udev_add_device(char *device, char *subsystem) { struct sysfs_class_device *class_dev; struct device_attr attr; - struct udevice dbdev; int major; int minor; char type; @@ -163,33 +163,17 @@ int udev_add_device(char *device, char *subsystem) retval = get_major_minor(class_dev, &major, &minor); if (retval) { - dbg ("get_major_minor failed"); + dbg("get_major_minor failed"); goto exit; } - memset(&dbdev, 0, sizeof(dbdev)); - strncpy(dbdev.name, attr.name, NAME_SIZE); - strncpy(dbdev.sysfs_path, class_dev->sysdevice->directory->path, - PATH_SIZE); - strncpy(dbdev.class_dev_name, class_dev->name, NAME_SIZE); - if ((sysfs_get_name_from_path(subsystem, dbdev.class_name, NAME_SIZE)) - != 0) - strcpy(dbdev.class_name, "unkown"); - strncpy(dbdev.bus_id, class_dev->sysdevice->bus_id, ID_SIZE); - strcpy(dbdev.bus_name, "unknown"); - if (class_dev->driver != NULL) - strncpy(dbdev.driver, class_dev->driver->name, NAME_SIZE); - else - strcpy(dbdev.driver, "unkown"); - dbdev.type = type; - dbdev.major = major; - dbdev.minor = minor; - dbdev.mode = attr.mode; - sysfs_close_class_device(class_dev); + retval = udevdb_add_device(device, class_dev, attr.name, type, major, minor, attr.mode); - retval = udevdb_add_udevice(&dbdev); if (retval != 0) - goto exit; + dbg("udevdb_add_device failed, but we are going to try to create the node anyway. " + "But remove might not work properly for this device."); + + sysfs_close_class_device(class_dev); return create_node(attr.name, type, major, minor, attr.mode);