From: Yu Watanabe Date: Wed, 2 Feb 2022 03:46:29 +0000 (+0900) Subject: sd-device: drop device_new_from_synthetic_event() from libsystemd X-Git-Tag: v251-rc1~371^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F22358%2Fhead;p=thirdparty%2Fsystemd.git sd-device: drop device_new_from_synthetic_event() from libsystemd It is used by only test-udev.c. --- diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 23f9ce97de9..8eb7198808c 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -858,31 +858,6 @@ int device_clone_with_db(sd_device *old_device, sd_device **new_device) { return 0; } -int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action) { - _cleanup_(sd_device_unrefp) sd_device *ret = NULL; - int r; - - assert(new_device); - assert(syspath); - assert(action); - - r = sd_device_new_from_syspath(&ret, syspath); - if (r < 0) - return r; - - r = device_read_uevent_file(ret); - if (r < 0) - return r; - - r = device_set_action_from_string(ret, action); - if (r < 0) - return r; - - *new_device = TAKE_PTR(ret); - - return 0; -} - int device_copy_properties(sd_device *device_dst, sd_device *device_src) { const char *property, *value; int r; diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h index 11f019f88a3..ec378076217 100644 --- a/src/libsystemd/sd-device/device-private.h +++ b/src/libsystemd/sd-device/device-private.h @@ -53,7 +53,6 @@ int device_rename(sd_device *device, const char *name); int device_shallow_clone(sd_device *old_device, sd_device **new_device); int device_clone_with_db(sd_device *old_device, sd_device **new_device); int device_copy_properties(sd_device *device_dst, sd_device *device_src); -int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action); int device_tag_index(sd_device *dev, sd_device *dev_old, bool add); int device_update_db(sd_device *device); diff --git a/src/test/test-udev.c b/src/test/test-udev.c index c0e779a813b..3ca132db3bc 100644 --- a/src/test/test-udev.c +++ b/src/test/test-udev.c @@ -25,6 +25,35 @@ #include "udev-event.h" #include "version.h" +static int device_new_from_synthetic_event(sd_device **ret, const char *syspath, const char *action) { + _cleanup_(sd_device_unrefp) sd_device *dev = NULL; + sd_device_action_t a; + int r; + + assert(ret); + assert(syspath); + assert(action); + + a = device_action_from_string(action); + if (a < 0) + return a; + + r = sd_device_new_from_syspath(&dev, syspath); + if (r < 0) + return r; + + r = device_read_uevent_file(dev); + if (r < 0) + return r; + + r = device_set_action(dev, a); + if (r < 0) + return r; + + *ret = TAKE_PTR(dev); + return 0; +} + static int fake_filesystems(void) { static const struct fakefs { const char *src;