+ /* set signal handlers */
+ act.sa_handler = (void (*) (int))sig_handler;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ /* alarm must not restart syscalls*/
+ sigaction(SIGALRM, &act, NULL);
+ sigaction(SIGINT, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
+
+ /* trigger timout to interrupt blocking syscalls */
+ alarm(ALARM_TIMEOUT);
+
+ switch(act_type) {
+ case UDEVSTART:
+ dbg("udevstart");
+ namedev_init();
+ retval = udev_start();
+ break;
+ case ADD:
+ dbg("udev add");
+
+ /* open the device */
+ snprintf(path, SYSFS_PATH_MAX, "%s%s", sysfs_path, udev.devpath);
+ class_dev = sysfs_open_class_device_path(path);
+ if (class_dev == NULL) {
+ dbg ("sysfs_open_class_device_path failed");
+ break;
+ }
+ dbg("opened class_dev->name='%s'", class_dev->name);
+
+ /* init rules */
+ namedev_init();
+
+ /* name, create node, store in db */
+ retval = udev_add_device(&udev, class_dev);
+
+ /* run scripts */
+ dev_d_execute(&udev);
+
+ sysfs_close_class_device(class_dev);
+ break;
+ case REMOVE:
+ dbg("udev remove");
+
+ /* get node from db, delete it*/
+ retval = udev_remove_device(&udev);
+
+ /* run scripts */
+ dev_d_execute(&udev);