mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
remove "ignore_remove" option
This commit is contained in:
parent
06ba47d833
commit
a89d342dfb
6
NEWS
6
NEWS
@ -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.
|
||||
|
@ -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)) {
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -975,16 +975,6 @@ EOF
|
||||
exp_name => "link4",
|
||||
rules => <<EOF
|
||||
SUBSYSTEMS=="scsi", PROGRAM=="/bin/echo -n node link1 link2 link3 link4", RESULT=="node *", SYMLINK+="%c{2+}"
|
||||
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
|
||||
},
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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];
|
||||
|
@ -435,13 +435,6 @@
|
||||
<listitem>
|
||||
<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>
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user