X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udevstart.c;h=bd91e96f6afcad2f3f198e0804e558540fcdaafc;hb=c9b8dbfb652a10d2f1c1b122a3806c21cab87ab4;hp=d41702efd17a4621199509ce4a1a207dc048404b;hpb=821d0ec803a72841f173739f5b713fe847edab75;p=elogind.git diff --git a/udevstart.c b/udevstart.c index d41702efd..bd91e96f6 100644 --- a/udevstart.c +++ b/udevstart.c @@ -37,6 +37,7 @@ #include "libsysfs/sysfs/libsysfs.h" #include "udev_libc_wrapper.h" +#include "udev_sysfs.h" #include "udev.h" #include "udev_version.h" #include "logging.h" @@ -110,22 +111,36 @@ static int add_device(const char *path, const char *subsystem) const char *devpath; devpath = &path[strlen(sysfs_path)]; - - /* set environment for callouts and dev.d/ */ setenv("DEVPATH", devpath, 1); setenv("SUBSYSTEM", subsystem, 1); - dbg("exec: '%s' (%s)\n", devpath, path); class_dev = sysfs_open_class_device_path(path); if (class_dev == NULL) { - dbg ("sysfs_open_class_device_path failed"); - return -ENODEV; + dbg("sysfs_open_class_device_path failed"); + return -1; } udev_init_device(&udev, devpath, subsystem, "add"); - udev_add_device(&udev, class_dev); + udev.devt = get_devt(class_dev); + if (!udev.devt) { + dbg("sysfs_open_class_device_path failed"); + return -1; + } + udev_rules_get_name(&udev, class_dev); + if (udev.ignore_device) { + dbg("device event will be ignored"); + goto exit; + } + if (udev.name[0] == '\0') { + dbg("device node creation supressed"); + goto run; + } + udev_add_device(&udev, class_dev); + if (udev.devname[0] != '\0') + setenv("DEVNAME", udev.devname, 1); +run: if (udev_run && !list_empty(&udev.run_list)) { struct name_entry *name_loop; @@ -133,13 +148,7 @@ static int add_device(const char *path, const char *subsystem) list_for_each_entry(name_loop, &udev.run_list, node) execute_command(name_loop->name, udev.subsystem); } - - /* run dev.d/ scripts if we created a node or changed a netif name */ - if (udev_dev_d && udev.devname[0] != '\0') { - setenv("DEVNAME", udev.devname, 1); - udev_multiplex_directory(&udev, DEVD_DIR, DEVD_SUFFIX); - } - +exit: sysfs_close_class_device(class_dev); udev_cleanup_device(&udev);