diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym index 78454acbc07..74eff7fcf08 100644 --- a/src/libsystemd/libsystemd.sym +++ b/src/libsystemd/libsystemd.sym @@ -749,4 +749,5 @@ global: sd_device_get_action; sd_device_get_seqnum; sd_device_new_from_stat_rdev; + sd_device_trigger; } LIBSYSTEMD_247; diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 28aca4063a4..1ef7f4d69c5 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -2036,3 +2036,15 @@ _public_ int sd_device_set_sysattr_valuef(sd_device *device, const char *sysattr return sd_device_set_sysattr_value(device, sysattr, value); } + +_public_ int sd_device_trigger(sd_device *device, sd_device_action_t action) { + const char *s; + + assert_return(device, -EINVAL); + + s = device_action_to_string(action); + if (!s) + return -EINVAL; + + return sd_device_set_sysattr_value(device, "uevent", s); +} diff --git a/src/systemd/sd-device.h b/src/systemd/sd-device.h index af0e26e2d76..310fcaa278a 100644 --- a/src/systemd/sd-device.h +++ b/src/systemd/sd-device.h @@ -99,6 +99,7 @@ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const ch int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *value); int sd_device_set_sysattr_valuef(sd_device *device, const char *sysattr, const char *format, ...) _sd_printf_(3, 4); +int sd_device_trigger(sd_device *device, sd_device_action_t action); /* device enumerator */