diff options
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | libudev/libudev-device-private.c | 4 | ||||
-rw-r--r-- | libudev/libudev-device.c | 17 | ||||
-rw-r--r-- | libudev/libudev-private.h | 2 | ||||
-rwxr-xr-x | test/udev-test.pl | 10 | ||||
-rw-r--r-- | udev/udev-node.c | 38 | ||||
-rw-r--r-- | udev/udev-rules.c | 14 | ||||
-rw-r--r-- | udev/udev.xml | 7 | ||||
-rw-r--r-- | udev/udevadm-info.c | 4 |
9 files changed, 28 insertions, 74 deletions
@@ -10,6 +10,12 @@ needed for usual hardware. Udev can not safely make assumptions about non-exixting partition major/minor numbers, and therefore no longer provide such an unreliable and unsafe option. +The option "ignore_remove" was removed from udev. With devtmpfs +udev passed control over device nodes to the kernel. This option +should no longer be needed, or can not work as advertised. Neither +udev nor the kernel will remove device nodes which are copied from +the /lib/udev/devices/ directory. + All "add|change" matches are replaced by "!remove" in the rules and in the udev logic. All types of events will update possible symlinks and permissions, only "remove" is handled special now. diff --git a/libudev/libudev-device-private.c b/libudev/libudev-device-private.c index 19c20b2cc8..5e4381ec27 100644 --- a/libudev/libudev-device-private.c +++ b/libudev/libudev-device-private.c @@ -41,8 +41,6 @@ int udev_device_update_db(struct udev_device *udev_device) udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) if (udev_list_entry_get_flags(list_entry)) goto file; - if (udev_device_get_ignore_remove(udev_device)) - goto file; if (udev_device_get_devlink_priority(udev_device) != 0) goto file; if (udev_device_get_event_timeout(udev_device) >= 0) @@ -93,8 +91,6 @@ file: fprintf(f, "L:%i\n", udev_device_get_devlink_priority(udev_device)); if (udev_device_get_event_timeout(udev_device) >= 0) fprintf(f, "T:%i\n", udev_device_get_event_timeout(udev_device)); - if (udev_device_get_ignore_remove(udev_device)) - fprintf(f, "R:%i\n", udev_device_get_ignore_remove(udev_device)); if (udev_device_get_watch_handle(udev_device) >= 0) fprintf(f, "W:%i\n", udev_device_get_watch_handle(udev_device)); udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device)) { diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c index 75cc61c5fc..b3b6a63114 100644 --- a/libudev/libudev-device.c +++ b/libudev/libudev-device.c @@ -75,7 +75,6 @@ struct udev_device { unsigned int envp_uptodate:1; unsigned int driver_set:1; unsigned int info_loaded:1; - unsigned int ignore_remove:1; }; struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value) @@ -283,9 +282,6 @@ int udev_device_read_db(struct udev_device *udev_device) case 'T': udev_device_set_event_timeout(udev_device, atoi(val)); break; - case 'R': - udev_device_set_ignore_remove(udev_device, atoi(val)); - break; case 'E': udev_device_add_property_from_string(udev_device, val); break; @@ -1434,19 +1430,6 @@ int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio) return 0; } -int udev_device_get_ignore_remove(struct udev_device *udev_device) -{ - if (!udev_device->info_loaded) - device_load_info(udev_device); - return udev_device->ignore_remove; -} - -int udev_device_set_ignore_remove(struct udev_device *udev_device, int ignore) -{ - udev_device->ignore_remove = ignore; - return 0; -} - int udev_device_get_watch_handle(struct udev_device *udev_device) { if (!udev_device->info_loaded) diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h index bf9e923b6d..8dc469ec9b 100644 --- a/libudev/libudev-private.h +++ b/libudev/libudev-private.h @@ -95,8 +95,6 @@ int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum); int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum); int udev_device_get_devlink_priority(struct udev_device *udev_device); int udev_device_set_devlink_priority(struct udev_device *udev_device, int prio); -int udev_device_get_ignore_remove(struct udev_device *udev_device); -int udev_device_set_ignore_remove(struct udev_device *udev_device, int ignore); int udev_device_get_watch_handle(struct udev_device *udev_device); int udev_device_set_watch_handle(struct udev_device *udev_device, int handle); void udev_device_set_info_loaded(struct udev_device *device); diff --git a/test/udev-test.pl b/test/udev-test.pl index 4633d6be25..a4d3a728f7 100755 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -978,16 +978,6 @@ SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT EOF }, { - desc => "ignore remove event test", - subsys => "block", - devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", - exp_name => "node", - exp_rem_error => "yes", - rules => <<EOF -SUBSYSTEMS=="scsi", KERNEL=="sda", SYMLINK+="node", OPTIONS="ignore_remove" -EOF - }, - { desc => "SUBSYSTEM match test", subsys => "block", devpath => "/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda", diff --git a/udev/udev-node.c b/udev/udev-node.c index 4492c2e393..34de268464 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -396,6 +396,8 @@ int udev_node_remove(struct udev_device *dev) struct udev_list_entry *list_entry; const char *devnode; struct stat stats; + struct udev_device *dev_check; + char filename[UTIL_PATH_SIZE]; int err = 0; /* remove/update symlinks, remove symlinks from name index */ @@ -404,32 +406,36 @@ int udev_node_remove(struct udev_device *dev) devnode = udev_device_get_devnode(dev); if (devnode == NULL) - return 0; + goto out; + if (stat(devnode, &stats) != 0) { info(udev, "device node '%s' not found\n", devnode); - return 0; + goto out; } + if (stats.st_rdev != udev_device_get_devnum(dev)) { info(udev, "device node '%s' points to a different device, skip removal\n", devnode); - return -1; + err = -1; + goto out; } - if (udev_device_get_ignore_remove(dev)) { - info(udev, "ignore_remove for '%s'\n", udev_device_get_devnode(dev)); - } else { - struct udev_device *dev_check; - - dev_check = udev_device_new_from_syspath(udev, udev_device_get_syspath(dev)); - if (dev_check != NULL && stats.st_rdev == udev_device_get_devnum(dev_check)) { - /* do not remove device node if the same sys-device is re-created in the meantime */ - info(udev, "keeping device node of existing device'%s'\n", devnode); - } else { - info(udev, "removing device node '%s'\n", devnode); - err = util_unlink_secure(udev, devnode); - } + dev_check = udev_device_new_from_syspath(udev, udev_device_get_syspath(dev)); + if (dev_check != NULL) { + /* do not remove device node if the same sys-device is re-created in the meantime */ + info(udev, "keeping device node of existing device'%s'\n", devnode); udev_device_unref(dev_check); + goto out; + } + + util_strscpyl(filename, sizeof(filename), LIBEXECDIR "/devices", &devnode[strlen(udev_get_dev_path(udev))], NULL); + if (stat(filename, &stats) == 0 || stats.st_rdev == udev_device_get_devnum(dev)) { + info(udev, "static device entry found '%s', skip removal\n", devnode); + goto out; } + info(udev, "removing device node '%s'\n", devnode); + err = util_unlink_secure(udev, devnode); util_delete_path(udev, devnode); +out: return err; } diff --git a/udev/udev-rules.c b/udev/udev-rules.c index a4a86b664a..4f18acaa78 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -1463,13 +1463,6 @@ static int add_rule(struct udev_rules *rules, char *line, err(rules->udev, "NAME=\"%%k\" is superfluous and breaks " "kernel supplied names, please remove it from %s:%u\n", filename, lineno); rule_add_key(&rule_tmp, TK_A_NAME, op, value, NULL); - attr = get_key_attribute(rules->udev, key + sizeof("NAME")-1); - if (attr != NULL) { - if (strstr(attr, "ignore_remove") != NULL) { - dbg(rules->udev, "remove event should be ignored\n"); - rule_add_key(&rule_tmp, TK_A_IGNORE_REMOVE, 0, NULL, NULL); - } - } } rule_tmp.rule.rule.flags = 1; continue; @@ -1540,10 +1533,6 @@ static int add_rule(struct udev_rules *rules, char *line, if (strcmp(key, "OPTIONS") == 0) { const char *pos; - if (strstr(value, "ignore_remove") != NULL) { - dbg(rules->udev, "remove event should be ignored\n"); - rule_add_key(&rule_tmp, TK_A_IGNORE_REMOVE, 0, NULL, NULL); - } pos = strstr(value, "link_priority="); if (pos != NULL) { int prio = atoi(&pos[strlen("link_priority=")]); @@ -2501,9 +2490,6 @@ int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event case TK_A_EVENT_TIMEOUT: udev_device_set_event_timeout(event->dev, cur->key.event_timeout); break; - case TK_A_IGNORE_REMOVE: - udev_device_set_ignore_remove(event->dev, 1); - break; case TK_A_ATTR: { const char *key_name = &rules->buf[cur->key.attr_off]; diff --git a/udev/udev.xml b/udev/udev.xml index 9275e0f79f..dce953dbce 100644 --- a/udev/udev.xml +++ b/udev/udev.xml @@ -436,13 +436,6 @@ <para>Rule and device options:</para> <variablelist> <varlistentry> - <term><option>ignore_remove</option></term> - <listitem> - <para>Do not remove the device node when the device goes away. This may be - useful as a workaround for broken device drivers.</para> - </listitem> - </varlistentry> - <varlistentry> <term><option>link_priority=<replaceable>value</replaceable></option></term> <listitem> <para>Specify the priority of the created symlinks. Devices with higher diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c index c57620feef..5f6209af2a 100644 --- a/udev/udevadm-info.c +++ b/udev/udevadm-info.c @@ -142,10 +142,6 @@ static void print_record(struct udev_device *device) if (i != 0) printf("L: %i\n", i); - i = udev_device_get_ignore_remove(device); - if (i != 0) - printf("R: %u\n", i); - i = udev_device_get_watch_handle(device); if (i >= 0) printf("W: %u\n", i); |