mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
udev: introduce ID_PROCESSING=1 boolean property
This indicates that the device is being processed by udevd.
This commit is contained in:
parent
4ebf678f1f
commit
f6bda694f9
@ -171,6 +171,12 @@ static int rename_netif(UdevEvent *event) {
|
||||
goto revert;
|
||||
}
|
||||
|
||||
r = device_add_property(event->dev_db_clone, "ID_PROCESSING", "1");
|
||||
if (r < 0) {
|
||||
log_device_warning_errno(event->dev_db_clone, r, "Failed to add 'ID_PROCESSING' property: %m");
|
||||
goto revert;
|
||||
}
|
||||
|
||||
r = device_update_db(event->dev_db_clone);
|
||||
if (r < 0) {
|
||||
log_device_debug_errno(event->dev_db_clone, r, "Failed to update database under /run/udev/data/: %m");
|
||||
@ -197,6 +203,7 @@ static int rename_netif(UdevEvent *event) {
|
||||
revert:
|
||||
/* Restore 'dev_db_clone' */
|
||||
(void) device_add_property(event->dev_db_clone, "ID_RENAMING", NULL);
|
||||
(void) device_add_property(event->dev_db_clone, "ID_PROCESSING", NULL);
|
||||
(void) device_update_db(event->dev_db_clone);
|
||||
|
||||
/* Restore 'dev' */
|
||||
@ -348,6 +355,18 @@ int udev_event_execute_rules(UdevEvent *event, UdevRules *rules) {
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(dev, r, "Failed to remove 'ID_RENAMING' property: %m");
|
||||
|
||||
/* If the database file already exists, append ID_PROCESSING property to the existing database,
|
||||
* to indicate that the device is being processed by udevd. */
|
||||
if (device_has_db(event->dev_db_clone) > 0) {
|
||||
r = device_add_property(event->dev_db_clone, "ID_PROCESSING", "1");
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(event->dev_db_clone, r, "Failed to add 'ID_PROCESSING' property: %m");
|
||||
|
||||
r = device_update_db(event->dev_db_clone);
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(event->dev_db_clone, r, "Failed to update database under /run/udev/data/: %m");
|
||||
}
|
||||
|
||||
DEVICE_TRACE_POINT(rules_start, dev);
|
||||
|
||||
r = udev_rules_apply_to_event(rules, event);
|
||||
@ -378,6 +397,15 @@ int udev_event_execute_rules(UdevEvent *event, UdevRules *rules) {
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(dev, r, "Failed to update tags under /run/udev/tag/: %m");
|
||||
|
||||
/* If the database file for the device will be created below, add ID_PROCESSING=1 to indicate that
|
||||
* the device is still being processed by udevd, as commands specified in RUN are invoked after
|
||||
* the database is created. See issue #30056. */
|
||||
if (device_should_have_db(dev) && !ordered_hashmap_isempty(event->run_list)) {
|
||||
r = device_add_property(dev, "ID_PROCESSING", "1");
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(dev, r, "Failed to add 'ID_PROCESSING' property: %m");
|
||||
}
|
||||
|
||||
r = device_update_db(dev);
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(dev, r, "Failed to update database under /run/udev/data/: %m");
|
||||
|
@ -212,6 +212,15 @@ static int worker_process_device(UdevWorker *worker, sd_device *dev) {
|
||||
log_device_warning_errno(dev, r, "Failed to add inotify watch, ignoring: %m");
|
||||
}
|
||||
|
||||
/* Finalize database. */
|
||||
r = device_add_property(dev, "ID_PROCESSING", NULL);
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(dev, r, "Failed to remove 'ID_PROCESSING' property: %m");
|
||||
|
||||
r = device_update_db(dev);
|
||||
if (r < 0)
|
||||
return log_device_warning_errno(dev, r, "Failed to update database under /run/udev/data/: %m");
|
||||
|
||||
log_device_uevent(dev, "Device processed");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user