udev: introduce log_device_uevent() helper function

And this drops duplicated check for seqnum and device action.
This commit is contained in:
Yu Watanabe
2020-12-10 12:26:19 +09:00
parent 481f24d1f6
commit b2d9e58f78
3 changed files with 20 additions and 30 deletions
+14
View File
@@ -324,6 +324,20 @@ bool device_for_action(sd_device *dev, DeviceAction action) {
return a == action;
}
void log_device_uevent(sd_device *device, const char *str) {
DeviceAction action = _DEVICE_ACTION_INVALID;
uint64_t seqnum = 0;
if (!DEBUG_LOGGING)
return;
(void) device_get_seqnum(device, &seqnum);
(void) device_get_action(device, &action);
log_device_debug(device, "%s%s(SEQNUM=%"PRIu64", ACTION=%s)",
strempty(str), isempty(str) ? "" : " ",
seqnum, strna(device_action_to_string(action)));
}
int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) {
char *i, *j;
int r;
+2
View File
@@ -33,4 +33,6 @@ int device_wait_for_devlink(const char *path, const char *subsystem, usec_t dead
int device_is_renaming(sd_device *dev);
bool device_for_action(sd_device *dev, DeviceAction action);
void log_device_uevent(sd_device *device, const char *str);
int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos);