mirror of
https://github.com/systemd/systemd.git
synced 2025-07-17 00:59:12 +03:00
if needed, store database entries also for devices which do not have a device node
This commit is contained in:
@ -56,11 +56,21 @@ int udev_device_update_db(struct udev_device *udev_device)
|
|||||||
udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device))
|
udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(udev_device))
|
||||||
if (udev_list_entry_get_flag(list_entry))
|
if (udev_list_entry_get_flag(list_entry))
|
||||||
goto file;
|
goto file;
|
||||||
if (udev_device_get_num_fake_partitions(udev_device))
|
if (udev_device_get_num_fake_partitions(udev_device) != 0)
|
||||||
goto file;
|
goto file;
|
||||||
if (udev_device_get_ignore_remove(udev_device))
|
if (udev_device_get_ignore_remove(udev_device))
|
||||||
goto file;
|
goto file;
|
||||||
/* try not to waste tmpfs memory; store values, if they fit, in a symlink target */
|
if (udev_device_get_devlink_priority(udev_device) != 0)
|
||||||
|
goto file;
|
||||||
|
if (udev_device_get_event_timeout(udev_device) >= 0)
|
||||||
|
goto file;
|
||||||
|
if (udev_device_get_devnode(udev_device) == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if we have only the node and symlinks to store, try not to waste
|
||||||
|
* tmpfs memory -- store values, if they fit, in a symlink target
|
||||||
|
*/
|
||||||
util_strlcpy(target, &udev_device_get_devnode(udev_device)[devlen], sizeof(target));
|
util_strlcpy(target, &udev_device_get_devnode(udev_device)[devlen], sizeof(target));
|
||||||
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device)) {
|
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device)) {
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -86,9 +96,11 @@ file:
|
|||||||
}
|
}
|
||||||
info(udev, "created db file for '%s' in '%s'\n", udev_device_get_devpath(udev_device), filename);
|
info(udev, "created db file for '%s' in '%s'\n", udev_device_get_devpath(udev_device), filename);
|
||||||
|
|
||||||
fprintf(f, "N:%s\n", &udev_device_get_devnode(udev_device)[devlen]);
|
if (udev_device_get_devnode(udev_device) != NULL) {
|
||||||
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device))
|
fprintf(f, "N:%s\n", &udev_device_get_devnode(udev_device)[devlen]);
|
||||||
fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]);
|
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(udev_device))
|
||||||
|
fprintf(f, "S:%s\n", &udev_list_entry_get_name(list_entry)[devlen]);
|
||||||
|
}
|
||||||
if (udev_device_get_devlink_priority(udev_device) != 0)
|
if (udev_device_get_devlink_priority(udev_device) != 0)
|
||||||
fprintf(f, "L:%u\n", udev_device_get_devlink_priority(udev_device));
|
fprintf(f, "L:%u\n", udev_device_get_devlink_priority(udev_device));
|
||||||
if (udev_device_get_event_timeout(udev_device) >= 0)
|
if (udev_device_get_event_timeout(udev_device) >= 0)
|
||||||
|
@ -611,6 +611,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
|
|||||||
/* add netif */
|
/* add netif */
|
||||||
if (strcmp(udev_device_get_subsystem(dev), "net") == 0 && strcmp(udev_device_get_action(dev), "add") == 0) {
|
if (strcmp(udev_device_get_subsystem(dev), "net") == 0 && strcmp(udev_device_get_action(dev), "add") == 0) {
|
||||||
dbg(event->udev, "netif add '%s'\n", udev_device_get_devpath(dev));
|
dbg(event->udev, "netif add '%s'\n", udev_device_get_devpath(dev));
|
||||||
|
udev_device_delete_db(dev);
|
||||||
|
|
||||||
udev_rules_apply_to_event(rules, event);
|
udev_rules_apply_to_event(rules, event);
|
||||||
if (event->ignore_device) {
|
if (event->ignore_device) {
|
||||||
@ -644,6 +645,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
|
|||||||
info(event->udev, "changed devpath to '%s'\n", udev_device_get_devpath(dev));
|
info(event->udev, "changed devpath to '%s'\n", udev_device_get_devpath(dev));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
udev_device_update_db(dev);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,6 +686,11 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules)
|
|||||||
udev_rules_apply_to_event(rules, event);
|
udev_rules_apply_to_event(rules, event);
|
||||||
if (event->ignore_device)
|
if (event->ignore_device)
|
||||||
info(event->udev, "device event will be ignored\n");
|
info(event->udev, "device event will be ignored\n");
|
||||||
|
|
||||||
|
if (strcmp(udev_device_get_action(dev), "remove") != 0)
|
||||||
|
udev_device_update_db(dev);
|
||||||
|
else
|
||||||
|
udev_device_delete_db(dev);
|
||||||
exit:
|
exit:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user