- default:
- /* parent reads from fds[0] */
- close(fds[1]);
- retval = 0;
- while (1) {
- res = read(fds[0], buffer, sizeof(buffer) - 1);
- if (res <= 0)
- break;
- buffer[res] = '\0';
- if (res > len) {
- dbg("result len %d too short", len);
- retval = -1;
- }
- if (value_set) {
- dbg("result value already set");
- retval = -1;
- } else {
- value_set = 1;
- strncpy(value, buffer, len);
- pos = value + strlen(value)-1;
- if (pos[0] == '\n')
- pos[0] = '\0';
- dbg("result is '%s'", value);
+
+ /* override built-in sysfs device */
+ udev->dev = dev;
+ strcpy(udev->action, "add");
+
+ if (strcmp(udev->dev->subsystem, "net") != 0) {
+ udev->devt = udev_device_get_devt(udev);
+ if (major(udev->devt) == 0)
+ return -1;
+ }
+
+ dbg("add '%s'", udev->dev->devpath);
+ setenv("DEVPATH", udev->dev->devpath, 1);
+ setenv("SUBSYSTEM", udev->dev->subsystem, 1);
+
+ udev_rules_get_name(&rules, udev);
+ if (udev->ignore_device) {
+ dbg("device event will be ignored");
+ goto exit;
+ }
+ if (udev->name[0] != '\0')
+ retval = udev_device_event(&rules, udev);
+ else
+ info("device node creation supressed");
+
+ if (retval == 0 && udev_run) {
+ struct name_entry *name_loop;
+
+ dbg("executing run list");
+ list_for_each_entry(name_loop, &udev->run_list, node) {
+ if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
+ pass_env_to_socket(&name_loop->name[strlen("socket:")], udev->dev->devpath, "add");
+ else {
+ char program[PATH_SIZE];
+
+ strlcpy(program, name_loop->name, sizeof(program));
+ udev_rules_apply_format(udev, program, sizeof(program));
+ run_program(program, udev->dev->subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO));