sd-device: introduce tiny wrapper sd_device_trigger()

This commit is contained in:
Yu Watanabe 2021-02-20 15:53:01 +09:00
parent 297d1370f8
commit f4d36efa75
3 changed files with 14 additions and 0 deletions

View File

@ -749,4 +749,5 @@ global:
sd_device_get_action;
sd_device_get_seqnum;
sd_device_new_from_stat_rdev;
sd_device_trigger;
} LIBSYSTEMD_247;

View File

@ -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);
}

View File

@ -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 */