mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
sd-device: make device_set_action() take sd_device_action_t
This commit is contained in:
parent
7f2e3eea28
commit
2079898088
@ -184,16 +184,11 @@ static int device_set_devgid(sd_device *device, const char *gid) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int device_set_action(sd_device *device, const char *action) {
|
||||
sd_device_action_t a;
|
||||
int device_set_action(sd_device *device, sd_device_action_t a) {
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(action);
|
||||
|
||||
a = device_action_from_string(action);
|
||||
if (a < 0)
|
||||
return a;
|
||||
assert(a >= 0 && a < _SD_DEVICE_ACTION_MAX);
|
||||
|
||||
r = device_add_property_internal(device, "ACTION", device_action_to_string(a));
|
||||
if (r < 0)
|
||||
@ -204,6 +199,19 @@ static int device_set_action(sd_device *device, const char *action) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int device_set_action_from_string(sd_device *device, const char *action) {
|
||||
sd_device_action_t a;
|
||||
|
||||
assert(device);
|
||||
assert(action);
|
||||
|
||||
a = device_action_from_string(action);
|
||||
if (a < 0)
|
||||
return a;
|
||||
|
||||
return device_set_action(device, a);
|
||||
}
|
||||
|
||||
static int device_set_seqnum(sd_device *device, const char *str) {
|
||||
uint64_t seqnum;
|
||||
int r;
|
||||
@ -307,7 +315,7 @@ static int device_amend(sd_device *device, const char *key, const char *value) {
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(device, r, "sd-device: Failed to set devgid to '%s': %m", value);
|
||||
} else if (streq(key, "ACTION")) {
|
||||
r = device_set_action(device, value);
|
||||
r = device_set_action_from_string(device, value);
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(device, r, "sd-device: Failed to set action to '%s': %m", value);
|
||||
} else if (streq(key, "SEQNUM")) {
|
||||
@ -866,7 +874,7 @@ int device_new_from_synthetic_event(sd_device **new_device, const char *syspath,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = device_set_action(ret, action);
|
||||
r = device_set_action_from_string(ret, action);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -66,6 +66,7 @@ static inline int device_read_db(sd_device *device) {
|
||||
|
||||
int device_read_uevent_file(sd_device *device);
|
||||
|
||||
int device_set_action(sd_device *device, sd_device_action_t a);
|
||||
sd_device_action_t device_action_from_string(const char *s) _pure_;
|
||||
const char *device_action_to_string(sd_device_action_t a) _const_;
|
||||
void dump_device_action_table(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user