diff options
author | Tom Gundersen <teg@jklm.no> | 2015-04-23 15:19:13 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-04-23 22:31:25 +0200 |
commit | 107f2e2526d476c6cc9b81a690391c111027d641 (patch) | |
tree | 7c6b71cc8e761b1083fb0ed42ba68f26a2fe15e5 /src | |
parent | 353f605867f9dac1eea4ad8ebaa92a004cbcd9e7 (diff) |
udevd: fix REMOVE handling
This reverts b67f944. Lazy loading of device properties does not work for devices
that are received over netlink, as these are sealed. Reinstate the unconditional
loading of the device db.
Reported by: Mantas Mikulėnas <grawity@gmail.com>.
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-device/device-internal.h | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-private.c | 6 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-private.h | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 8 | ||||
-rw-r--r-- | src/libudev/libudev-device-private.c | 6 | ||||
-rw-r--r-- | src/libudev/libudev-private.h | 1 | ||||
-rw-r--r-- | src/udev/udev-event.c | 7 |
7 files changed, 25 insertions, 5 deletions
diff --git a/src/libsystemd/sd-device/device-internal.h b/src/libsystemd/sd-device/device-internal.h index 59ec1a6d73..b96441de56 100644 --- a/src/libsystemd/sd-device/device-internal.h +++ b/src/libsystemd/sd-device/device-internal.h @@ -110,6 +110,7 @@ int device_new_aux(sd_device **ret); int device_add_property_aux(sd_device *device, const char *key, const char *value, bool db); int device_add_property_internal(sd_device *device, const char *key, const char *value); int device_read_uevent_file(sd_device *device); +int device_read_db_aux(sd_device *device, bool force); int device_set_syspath(sd_device *device, const char *_syspath, bool verify); int device_set_ifindex(sd_device *device, const char *ifindex); diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 9788df769c..3cadedbf4a 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -1100,3 +1100,9 @@ int device_delete_db(sd_device *device) { return 0; } + +int device_read_db_force(sd_device *device) { + assert(device); + + return device_read_db_aux(device, true); +} diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h index f25248150e..49a7b66a2b 100644 --- a/src/libsystemd/sd-device/device-private.h +++ b/src/libsystemd/sd-device/device-private.h @@ -61,3 +61,4 @@ int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, int device_tag_index(sd_device *dev, sd_device *dev_old, bool add); int device_update_db(sd_device *device); int device_delete_db(sd_device *device); +int device_read_db_force(sd_device *device); diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 7a7b323f3c..fd4622987c 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1220,7 +1220,7 @@ int device_get_id_filename(sd_device *device, const char **ret) { return 0; } -static int device_read_db(sd_device *device) { +int device_read_db_aux(sd_device *device, bool force) { _cleanup_free_ char *db = NULL; char *path; const char *id, *value; @@ -1237,7 +1237,7 @@ static int device_read_db(sd_device *device) { INVALID_LINE, } state = PRE_KEY; - if (device->db_loaded || device->sealed) + if (device->db_loaded || (!force && device->sealed)) return 0; r = device_get_id_filename(device, &id); @@ -1313,6 +1313,10 @@ static int device_read_db(sd_device *device) { return 0; } +static int device_read_db(sd_device *device) { + return device_read_db_aux(device, false); +} + _public_ int sd_device_get_is_initialized(sd_device *device, int *initialized) { int r; diff --git a/src/libudev/libudev-device-private.c b/src/libudev/libudev-device-private.c index bb4d7e6dad..4b9c053b54 100644 --- a/src/libudev/libudev-device-private.c +++ b/src/libudev/libudev-device-private.c @@ -407,3 +407,9 @@ void udev_device_set_info_loaded(struct udev_device *udev_device) { device_seal(udev_device->device); } + +void udev_device_read_db(struct udev_device *udev_device) { + assert(udev_device); + + device_read_db_force(udev_device->device); +} diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h index 32c5e19a12..cbe84aa0dd 100644 --- a/src/libudev/libudev-private.h +++ b/src/libudev/libudev-private.h @@ -67,6 +67,7 @@ int udev_device_get_ifindex(struct udev_device *udev_device); void udev_device_set_info_loaded(struct udev_device *device); bool udev_device_get_db_persist(struct udev_device *udev_device); void udev_device_set_db_persist(struct udev_device *udev_device); +void udev_device_read_db(struct udev_device *udev_device); /* libudev-device-private.c */ int udev_device_update_db(struct udev_device *udev_device); diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 978b21832d..2fa26a40be 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -794,6 +794,10 @@ void udev_event_execute_rules(struct udev_event *event, return; if (streq(udev_device_get_action(dev), "remove")) { + udev_device_read_db(dev); + udev_device_tag_index(dev, NULL, false); + udev_device_delete_db(dev); + if (major(udev_device_get_devnum(dev)) != 0) udev_watch_end(event->udev, dev); @@ -804,9 +808,6 @@ void udev_event_execute_rules(struct udev_event *event, if (major(udev_device_get_devnum(dev)) != 0) udev_node_remove(dev); - - udev_device_delete_db(dev); - udev_device_tag_index(dev, NULL, false); } else { event->dev_db = udev_device_clone_with_db(dev); if (event->dev_db != NULL) { |