summaryrefslogtreecommitdiff
path: root/udevstart.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2005-06-05 15:55:29 +0200
committerKay Sievers <kay.sievers@suse.de>2005-06-05 15:55:29 +0200
commitc07669bd663d780e4957691e488798aa0178e76b (patch)
treed820e2e62ca315aedb05ba5fa12fec006ad0720b /udevstart.c
parentc2401132bf72cbda6555f1ef4403851c14faeba5 (diff)
udev: handle all events - not only class and block devices
Handle all events with rules. If udev is expected to handle hotplug.d/ the exernal helper must be called. Signed-off-by: Kay Sievers <kay.sievers@suse.de>
Diffstat (limited to 'udevstart.c')
-rw-r--r--udevstart.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/udevstart.c b/udevstart.c
index 34f3835d65..d1a0a8379c 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,25 +111,37 @@ 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;
+ 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) {
+ info("device event will be ignored");
+ goto exit;
+ }
+ if (udev.name[0] == '\0') {
+ info("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;
@@ -137,6 +150,7 @@ static int add_device(const char *path, const char *subsystem)
execute_command(name_loop->name, udev.subsystem);
}
+exit:
sysfs_close_class_device(class_dev);
udev_cleanup_device(&udev);