]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevd: fix REMOVE handling
authorTom Gundersen <teg@jklm.no>
Thu, 23 Apr 2015 13:19:13 +0000 (15:19 +0200)
committerTom Gundersen <teg@jklm.no>
Thu, 23 Apr 2015 20:31:25 +0000 (22:31 +0200)
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>.

src/libsystemd/sd-device/device-internal.h
src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/device-private.h
src/libsystemd/sd-device/sd-device.c
src/libudev/libudev-device-private.c
src/libudev/libudev-private.h
src/udev/udev-event.c

index 59ec1a6d73eb6f05c4ce9165582da7ff1bfd46a8..b96441de56960a0ec4d80027b1d6ec288a6973c6 100644 (file)
@@ -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);
index 9788df769cfbf249e730da89838a26092974523b..3cadedbf4a6e513ee106b7988e865c2ff23489ae 100644 (file)
@@ -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);
+}
index f25248150ec30e6497eaef2fc7ddc6cc11237137..49a7b66a2b1a02e96b3b6e5e69c34330322b2aab 100644 (file)
@@ -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);
index 7a7b323f3ce61ab4d57668cb454f55a724f504a7..fd4622987c04f91c15401156b0eadb55e95ab854 100644 (file)
@@ -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;
 
index bb4d7e6dade39fe095af42da41d72ca7f48eb0a5..4b9c053b54e842991331f3e9f24253fc4dfd77e5 100644 (file)
@@ -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);
+}
index 32c5e19a127d2e57bdd7ab8c33c58e7d35edbaa3..cbe84aa0dd57e0942df62b902c6eb11c2eb2df71 100644 (file)
@@ -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);
index 978b21832d7d976f15a5865cd782963c7dc936d9..2fa26a40be182b2e7d7c683c7c733709ec3cadb6 100644 (file)
@@ -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) {