mirror of
https://github.com/systemd/systemd.git
synced 2025-09-05 01:44:45 +03:00
sd-device: make device_set_action() take sd_device_action_t
This commit is contained in:
@@ -184,16 +184,11 @@ static int device_set_devgid(sd_device *device, const char *gid) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int device_set_action(sd_device *device, const char *action) {
|
int device_set_action(sd_device *device, sd_device_action_t a) {
|
||||||
sd_device_action_t a;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(device);
|
assert(device);
|
||||||
assert(action);
|
assert(a >= 0 && a < _SD_DEVICE_ACTION_MAX);
|
||||||
|
|
||||||
a = device_action_from_string(action);
|
|
||||||
if (a < 0)
|
|
||||||
return a;
|
|
||||||
|
|
||||||
r = device_add_property_internal(device, "ACTION", device_action_to_string(a));
|
r = device_add_property_internal(device, "ACTION", device_action_to_string(a));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
@@ -204,6 +199,19 @@ static int device_set_action(sd_device *device, const char *action) {
|
|||||||
return 0;
|
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) {
|
static int device_set_seqnum(sd_device *device, const char *str) {
|
||||||
uint64_t seqnum;
|
uint64_t seqnum;
|
||||||
int r;
|
int r;
|
||||||
@@ -307,7 +315,7 @@ static int device_amend(sd_device *device, const char *key, const char *value) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_debug_errno(device, r, "sd-device: Failed to set devgid to '%s': %m", value);
|
return log_device_debug_errno(device, r, "sd-device: Failed to set devgid to '%s': %m", value);
|
||||||
} else if (streq(key, "ACTION")) {
|
} else if (streq(key, "ACTION")) {
|
||||||
r = device_set_action(device, value);
|
r = device_set_action_from_string(device, value);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return log_device_debug_errno(device, r, "sd-device: Failed to set action to '%s': %m", value);
|
return log_device_debug_errno(device, r, "sd-device: Failed to set action to '%s': %m", value);
|
||||||
} else if (streq(key, "SEQNUM")) {
|
} 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)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
r = device_set_action(ret, action);
|
r = device_set_action_from_string(ret, action);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
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_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_;
|
sd_device_action_t device_action_from_string(const char *s) _pure_;
|
||||||
const char *device_action_to_string(sd_device_action_t a) _const_;
|
const char *device_action_to_string(sd_device_action_t a) _const_;
|
||||||
void dump_device_action_table(void);
|
void dump_device_action_table(void);
|
||||||
|
Reference in New Issue
Block a user