From 52a4d0c0d509e89571fdd7233b9b259c5fcafe52 Mon Sep 17 00:00:00 2001 From: Chris Clayton Date: Thu, 18 Jun 2015 13:22:13 -0400 Subject: udevd: fix REMOVE handling The original upstream commit is at http://cgit.freedesktop.org/systemd/systemd/commit/?id=107f2e2526d476c6cc9b81a690391c111027d641 This was reworked by Chris Clayton for eudev. Signed-off-by: Anthony G. Basile --- src/libudev/libudev-device.c | 3 +-- src/libudev/libudev.h | 1 + src/udev/udev-event.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c index 9e6a45efa6..ed9964ac44 100644 --- a/src/libudev/libudev-device.c +++ b/src/libudev/libudev-device.c @@ -37,7 +37,6 @@ #include "libudev-private.h" static int udev_device_read_uevent_file(struct udev_device *udev_device); -static int udev_device_read_db(struct udev_device *udev_device); static int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode); static struct udev_list_entry *udev_device_add_property_internal(struct udev_device *udev_device, const char *key, const char *value); @@ -594,7 +593,7 @@ _public_ const char *udev_device_get_property_value(struct udev_device *udev_dev return udev_list_entry_get_value(list_entry); } -static int udev_device_read_db(struct udev_device *udev_device) +int udev_device_read_db(struct udev_device *udev_device) { char filename[UTIL_PATH_SIZE]; char line[UTIL_LINE_SIZE]; diff --git a/src/libudev/libudev.h b/src/libudev/libudev.h index a94505c09e..8a2441a825 100644 --- a/src/libudev/libudev.h +++ b/src/libudev/libudev.h @@ -88,6 +88,7 @@ struct udev_device *udev_device_get_parent(struct udev_device *udev_device); struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype); /* retrieve device properties */ +int udev_device_read_db(struct udev_device *udev_device); const char *udev_device_get_devpath(struct udev_device *udev_device); const char *udev_device_get_subsystem(struct udev_device *udev_device); const char *udev_device_get_devtype(struct udev_device *udev_device); diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 8db287b141..ed6f203ce7 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -811,6 +811,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); @@ -821,9 +825,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) { -- cgit v1.2.3