mirror of
https://github.com/systemd/systemd
synced 2024-09-06 08:46:19 +00:00
Merge pull request #10884 from yuwata/udev-debug
meson: add more debug options
This commit is contained in:
commit
74a01105b7
10
meson.build
10
meson.build
|
@ -782,17 +782,25 @@ substs.set('DEBUGTTY', get_option('debug-tty'))
|
|||
|
||||
enable_debug_hashmap = false
|
||||
enable_debug_mmap_cache = false
|
||||
enable_debug_siphash = false
|
||||
enable_debug_udev = false
|
||||
foreach name : get_option('debug-extra')
|
||||
if name == 'hashmap'
|
||||
enable_debug_hashmap = true
|
||||
elif name == 'mmap-cache'
|
||||
enable_debug_mmap_cache = true
|
||||
elif name == 'siphash'
|
||||
enable_debug_siphash = true
|
||||
elif name == 'udev'
|
||||
enable_debug_udev = true
|
||||
else
|
||||
message('unknown debug option "@0@", ignoring'.format(name))
|
||||
endif
|
||||
endforeach
|
||||
conf.set10('ENABLE_DEBUG_HASHMAP', enable_debug_hashmap)
|
||||
conf.set10('ENABLE_DEBUG_MMAP_CACHE', enable_debug_mmap_cache)
|
||||
conf.set10('ENABLE_DEBUG_SIPHASH', enable_debug_siphash)
|
||||
conf.set10('ENABLE_DEBUG_UDEV', enable_debug_udev)
|
||||
|
||||
conf.set10('VALGRIND', get_option('valgrind'))
|
||||
conf.set10('LOG_TRACE', get_option('log-trace'))
|
||||
|
@ -3128,6 +3136,8 @@ foreach tuple : [
|
|||
['gshadow'],
|
||||
['debug hashmap'],
|
||||
['debug mmap cache'],
|
||||
['debug siphash'],
|
||||
['debug udev'],
|
||||
['valgrind', conf.get('VALGRIND') == 1],
|
||||
['trace logging', conf.get('LOG_TRACE') == 1],
|
||||
['link-udev-shared', get_option('link-udev-shared')],
|
||||
|
|
|
@ -45,7 +45,7 @@ option('debug-shell', type : 'string', value : '/bin/sh',
|
|||
description : 'path to debug shell binary')
|
||||
option('debug-tty', type : 'string', value : '/dev/tty9',
|
||||
description : 'specify the tty device for debug shell')
|
||||
option('debug-extra', type : 'array', choices : ['hashmap', 'mmap-cache'], value : [],
|
||||
option('debug-extra', type : 'array', choices : ['hashmap', 'mmap-cache', 'siphash', 'udev'], value : [],
|
||||
description : 'enable extra debugging')
|
||||
option('memory-accounting-default', type : 'boolean',
|
||||
description : 'enable MemoryAccounting= by default')
|
||||
|
|
|
@ -90,7 +90,7 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
|
|||
/* We did not have enough input to fill out the padding completely */
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if ENABLE_DEBUG_SIPHASH
|
||||
printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0);
|
||||
printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t) state->v1);
|
||||
printf("(%3zu) v2 %08x %08x\n", state->inlen, (uint32_t) (state->v2 >> 32), (uint32_t) state->v2);
|
||||
|
@ -110,7 +110,7 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
|
|||
|
||||
for ( ; in < end; in += 8) {
|
||||
m = unaligned_read_le64(in);
|
||||
#ifdef DEBUG
|
||||
#if ENABLE_DEBUG_SIPHASH
|
||||
printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0);
|
||||
printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t) state->v1);
|
||||
printf("(%3zu) v2 %08x %08x\n", state->inlen, (uint32_t) (state->v2 >> 32), (uint32_t) state->v2);
|
||||
|
@ -158,7 +158,7 @@ uint64_t siphash24_finalize(struct siphash *state) {
|
|||
|
||||
b = state->padding | (((uint64_t) state->inlen) << 56);
|
||||
|
||||
#ifdef DEBUG
|
||||
#if ENABLE_DEBUG_SIPHASH
|
||||
printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0);
|
||||
printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t) state->v1);
|
||||
printf("(%3zu) v2 %08x %08x\n", state->inlen, (uint32_t) (state->v2 >> 32), (uint32_t) state->v2);
|
||||
|
@ -171,7 +171,7 @@ uint64_t siphash24_finalize(struct siphash *state) {
|
|||
sipround(state);
|
||||
state->v0 ^= b;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if ENABLE_DEBUG_SIPHASH
|
||||
printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0);
|
||||
printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t) state->v1);
|
||||
printf("(%3zu) v2 %08x %08x\n", state->inlen, (uint32_t) (state->v2 >> 32), (uint32_t) state->v2);
|
||||
|
|
|
@ -55,7 +55,7 @@ static int fake_filesystems(void) {
|
|||
}
|
||||
|
||||
static int run(int argc, char *argv[]) {
|
||||
_cleanup_(udev_rules_unrefp) struct udev_rules *rules = NULL;
|
||||
_cleanup_(udev_rules_freep) struct udev_rules *rules = NULL;
|
||||
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
|
||||
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
||||
const char *devpath, *devname, *action;
|
||||
|
|
|
@ -221,7 +221,7 @@ struct rule_tmp {
|
|||
unsigned token_cur;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
#if ENABLE_DEBUG_UDEV
|
||||
static const char *operation_str(enum operation_type type) {
|
||||
static const char *operation_strs[] = {
|
||||
[OP_UNSET] = "UNSET",
|
||||
|
@ -423,7 +423,7 @@ static void dump_token(struct udev_rules *rules, struct token *token) {
|
|||
case TK_M_PARENTS_MAX:
|
||||
case TK_M_MAX:
|
||||
case TK_UNSET:
|
||||
log_debug("unknown type %u", type);
|
||||
log_debug("Unknown token type %u", type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ static void dump_token(struct udev_rules *rules, struct token *token) {
|
|||
static void dump_rules(struct udev_rules *rules) {
|
||||
unsigned i;
|
||||
|
||||
log_debug("dumping %u (%zu bytes) tokens, %zu (%zu bytes) strings",
|
||||
log_debug("Dumping %u (%zu bytes) tokens, %zu (%zu bytes) strings",
|
||||
rules->token_cur,
|
||||
rules->token_cur * sizeof(struct token),
|
||||
rules->strbuf->nodes_count,
|
||||
|
@ -442,7 +442,7 @@ static void dump_rules(struct udev_rules *rules) {
|
|||
#else
|
||||
static inline void dump_token(struct udev_rules *rules, struct token *token) {}
|
||||
static inline void dump_rules(struct udev_rules *rules) {}
|
||||
#endif /* DEBUG */
|
||||
#endif /* ENABLE_DEBUG_UDEV */
|
||||
|
||||
static int add_token(struct udev_rules *rules, struct token *token) {
|
||||
/* grow buffer if needed */
|
||||
|
@ -456,7 +456,7 @@ static int add_token(struct udev_rules *rules, struct token *token) {
|
|||
add = 8;
|
||||
|
||||
tokens = reallocarray(rules->tokens, rules->token_max + add, sizeof(struct token));
|
||||
if (tokens == NULL)
|
||||
if (!tokens)
|
||||
return -1;
|
||||
rules->tokens = tokens;
|
||||
rules->token_max += add;
|
||||
|
@ -470,7 +470,7 @@ static void log_unknown_owner(int error, const char *entity, const char *owner)
|
|||
if (IN_SET(abs(error), ENOENT, ESRCH))
|
||||
log_error("Specified %s '%s' unknown", entity, owner);
|
||||
else
|
||||
log_error_errno(error, "Error resolving %s '%s': %m", entity, owner);
|
||||
log_error_errno(error, "Failed to resolve %s '%s': %m", entity, owner);
|
||||
}
|
||||
|
||||
static uid_t add_uid(struct udev_rules *rules, const char *owner) {
|
||||
|
@ -502,7 +502,7 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner) {
|
|||
add = 8;
|
||||
|
||||
uids = reallocarray(rules->uids, rules->uids_max + add, sizeof(struct uid_gid));
|
||||
if (uids == NULL)
|
||||
if (!uids)
|
||||
return uid;
|
||||
rules->uids = uids;
|
||||
rules->uids_max += add;
|
||||
|
@ -545,7 +545,7 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) {
|
|||
add = 8;
|
||||
|
||||
gids = reallocarray(rules->gids, rules->gids_max + add, sizeof(struct uid_gid));
|
||||
if (gids == NULL)
|
||||
if (!gids)
|
||||
return gid;
|
||||
rules->gids = gids;
|
||||
rules->gids_max += add;
|
||||
|
@ -607,7 +607,7 @@ static int import_property_from_string(sd_device *dev, char *line) {
|
|||
if (IN_SET(val[0], '"', '\'')) {
|
||||
if (len == 1 || val[len-1] != val[0])
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"inconsistent quoting: '%s', skip",
|
||||
"Inconsistent quoting: '%s', skip",
|
||||
line);
|
||||
val[len-1] = '\0';
|
||||
val++;
|
||||
|
@ -651,11 +651,11 @@ static int import_program_into_properties(struct udev_event *event,
|
|||
return err;
|
||||
|
||||
line = result;
|
||||
while (line != NULL) {
|
||||
while (line) {
|
||||
char *pos;
|
||||
|
||||
pos = strchr(line, '\n');
|
||||
if (pos != NULL) {
|
||||
if (pos) {
|
||||
pos[0] = '\0';
|
||||
pos = &pos[1];
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ static void attr_subst_subdir(char *attr, size_t len) {
|
|||
tail = pos + 2;
|
||||
path = strndupa(attr, pos - attr + 1); /* include slash at end */
|
||||
dir = opendir(path);
|
||||
if (dir == NULL)
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
FOREACH_DIRENT_ALL(dent, dir, break)
|
||||
|
@ -716,7 +716,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
|||
unsigned i, j;
|
||||
|
||||
linepos = *line;
|
||||
if (linepos == NULL || linepos[0] == '\0')
|
||||
if (!linepos || linepos[0] == '\0')
|
||||
return -1;
|
||||
|
||||
/* skip whitespace */
|
||||
|
@ -817,10 +817,10 @@ static const char *get_key_attribute(char *str) {
|
|||
char *attr;
|
||||
|
||||
attr = strchr(str, '{');
|
||||
if (attr != NULL) {
|
||||
if (attr) {
|
||||
attr++;
|
||||
pos = strchr(attr, '}');
|
||||
if (pos == NULL) {
|
||||
if (!pos) {
|
||||
log_error("Missing closing brace for format");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -888,7 +888,7 @@ static void rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
|
|||
break;
|
||||
case TK_M_TEST:
|
||||
token->key.value_off = rules_add_string(rule_tmp->rules, value);
|
||||
if (data != NULL)
|
||||
if (data)
|
||||
token->key.mode = *(mode_t *)data;
|
||||
break;
|
||||
case TK_A_STRING_ESCAPE_NONE:
|
||||
|
@ -922,44 +922,43 @@ static void rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
|
|||
assert_not_reached("wrong type");
|
||||
}
|
||||
|
||||
if (value != NULL && type < TK_M_MAX) {
|
||||
if (value && type < TK_M_MAX) {
|
||||
/* check if we need to split or call fnmatch() while matching rules */
|
||||
enum string_glob_type glob;
|
||||
int has_split;
|
||||
int has_glob;
|
||||
bool has_split, has_glob;
|
||||
|
||||
has_split = (strchr(value, '|') != NULL);
|
||||
has_split = strchr(value, '|');
|
||||
has_glob = string_is_glob(value);
|
||||
if (has_split && has_glob) {
|
||||
if (has_split && has_glob)
|
||||
glob = GL_SPLIT_GLOB;
|
||||
} else if (has_split) {
|
||||
else if (has_split)
|
||||
glob = GL_SPLIT;
|
||||
} else if (has_glob) {
|
||||
else if (has_glob) {
|
||||
if (streq(value, "?*"))
|
||||
glob = GL_SOMETHING;
|
||||
else
|
||||
glob = GL_GLOB;
|
||||
} else {
|
||||
} else
|
||||
glob = GL_PLAIN;
|
||||
}
|
||||
|
||||
token->key.glob = glob;
|
||||
}
|
||||
|
||||
if (value != NULL && type > TK_M_MAX) {
|
||||
if (value && type > TK_M_MAX) {
|
||||
/* check if assigned value has substitution chars */
|
||||
if (value[0] == '[')
|
||||
token->key.subst = SB_SUBSYS;
|
||||
else if (strchr(value, '%') != NULL || strchr(value, '$') != NULL)
|
||||
else if (strchr(value, '%') || strchr(value, '$'))
|
||||
token->key.subst = SB_FORMAT;
|
||||
else
|
||||
token->key.subst = SB_NONE;
|
||||
}
|
||||
|
||||
if (attr != NULL) {
|
||||
if (attr) {
|
||||
/* check if property/attribute name has substitution chars */
|
||||
if (attr[0] == '[')
|
||||
token->key.attrsubst = SB_SUBSYS;
|
||||
else if (strchr(attr, '%') != NULL || strchr(attr, '$') != NULL)
|
||||
else if (strchr(attr, '%') || strchr(attr, '$'))
|
||||
token->key.attrsubst = SB_FORMAT;
|
||||
else
|
||||
token->key.attrsubst = SB_NONE;
|
||||
|
@ -1004,9 +1003,10 @@ static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define LOG_RULE_ERROR(fmt, ...) log_error("Invalid rule %s:%u: " fmt, filename, lineno, ##__VA_ARGS__)
|
||||
#define LOG_RULE_WARNING(fmt, ...) log_warning("%s:%u: " fmt, filename, lineno, ##__VA_ARGS__)
|
||||
#define LOG_RULE_DEBUG(fmt, ...) log_debug("%s:%u: " fmt, filename, lineno, ##__VA_ARGS__)
|
||||
#define LOG_RULE_FULL(level, fmt, ...) log_full(level, "%s:%u: " fmt, filename, lineno, ##__VA_ARGS__)
|
||||
#define LOG_RULE_ERROR(fmt, ...) LOG_RULE_FULL(LOG_ERR, fmt, ##__VA_ARGS__)
|
||||
#define LOG_RULE_WARNING(fmt, ...) LOG_RULE_FULL(LOG_WARNING, fmt, ##__VA_ARGS__)
|
||||
#define LOG_RULE_DEBUG(fmt, ...) LOG_RULE_FULL(LOG_DEBUG, fmt, ##__VA_ARGS__)
|
||||
#define LOG_AND_RETURN(fmt, ...) { LOG_RULE_ERROR(fmt, __VA_ARGS__); return; }
|
||||
|
||||
static void add_rule(struct udev_rules *rules, char *line,
|
||||
|
@ -1043,38 +1043,37 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
_cleanup_free_ char *tmp;
|
||||
|
||||
tmp = cescape(buf);
|
||||
log_error("invalid key/value pair in file %s on line %u, starting at character %tu ('%s')",
|
||||
filename, lineno, linepos - line + 1, tmp);
|
||||
LOG_RULE_ERROR("Invalid key/value pair, starting at character %tu ('%s')", linepos - line + 1, tmp);
|
||||
if (*linepos == '#')
|
||||
log_error("hint: comments can only start at beginning of line");
|
||||
LOG_RULE_ERROR("Hint: comments can only start at beginning of line");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (rule_tmp.token_cur >= ELEMENTSOF(rule_tmp.token))
|
||||
LOG_AND_RETURN("temporary rule array too small, aborting event processing with %u items", rule_tmp.token_cur);
|
||||
LOG_AND_RETURN("Temporary rule array too small, aborting event processing with %u items", rule_tmp.token_cur);
|
||||
|
||||
if (streq(key, "ACTION")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_ACTION, op, value, NULL);
|
||||
|
||||
} else if (streq(key, "DEVPATH")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_DEVPATH, op, value, NULL);
|
||||
|
||||
} else if (streq(key, "KERNEL")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_KERNEL, op, value, NULL);
|
||||
|
||||
} else if (streq(key, "SUBSYSTEM")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
/* bus, class, subsystem events should all be the same */
|
||||
if (STR_IN_SET(value, "subsystem", "bus", "class")) {
|
||||
|
@ -1087,17 +1086,17 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
} else if (streq(key, "DRIVER")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_DRIVER, op, value, NULL);
|
||||
|
||||
} else if (startswith(key, "ATTR{")) {
|
||||
attr = get_key_attribute(key + STRLEN("ATTR"));
|
||||
if (attr == NULL)
|
||||
LOG_AND_RETURN("error parsing %s attribute", "ATTR");
|
||||
if (!attr)
|
||||
LOG_AND_RETURN("Failed to parse %s attribute", "ATTR");
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", "ATTR");
|
||||
LOG_AND_RETURN("Invalid %s operation", "ATTR");
|
||||
|
||||
if (op < OP_MATCH_MAX)
|
||||
rule_add_key(&rule_tmp, TK_M_ATTR, op, value, attr);
|
||||
|
@ -1106,11 +1105,11 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
} else if (startswith(key, "SYSCTL{")) {
|
||||
attr = get_key_attribute(key + STRLEN("SYSCTL"));
|
||||
if (attr == NULL)
|
||||
LOG_AND_RETURN("error parsing %s attribute", "ATTR");
|
||||
if (!attr)
|
||||
LOG_AND_RETURN("Failed to parse %s attribute", "ATTR");
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", "ATTR");
|
||||
LOG_AND_RETURN("Invalid %s operation", "ATTR");
|
||||
|
||||
if (op < OP_MATCH_MAX)
|
||||
rule_add_key(&rule_tmp, TK_M_SYSCTL, op, value, attr);
|
||||
|
@ -1119,59 +1118,59 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
} else if (startswith(key, "SECLABEL{")) {
|
||||
attr = get_key_attribute(key + STRLEN("SECLABEL"));
|
||||
if (attr == NULL)
|
||||
LOG_AND_RETURN("error parsing %s attribute", "SECLABEL");
|
||||
if (!attr)
|
||||
LOG_AND_RETURN("Failed to parse %s attribute", "SECLABEL");
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", "SECLABEL");
|
||||
LOG_AND_RETURN("Invalid %s operation", "SECLABEL");
|
||||
|
||||
rule_add_key(&rule_tmp, TK_A_SECLABEL, op, value, attr);
|
||||
|
||||
} else if (streq(key, "KERNELS")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_KERNELS, op, value, NULL);
|
||||
|
||||
} else if (streq(key, "SUBSYSTEMS")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_SUBSYSTEMS, op, value, NULL);
|
||||
|
||||
} else if (streq(key, "DRIVERS")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_DRIVERS, op, value, NULL);
|
||||
|
||||
} else if (startswith(key, "ATTRS{")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", "ATTRS");
|
||||
LOG_AND_RETURN("Invalid %s operation", "ATTRS");
|
||||
|
||||
attr = get_key_attribute(key + STRLEN("ATTRS"));
|
||||
if (attr == NULL)
|
||||
LOG_AND_RETURN("error parsing %s attribute", "ATTRS");
|
||||
if (!attr)
|
||||
LOG_AND_RETURN("Failed to parse %s attribute", "ATTRS");
|
||||
|
||||
if (startswith(attr, "device/"))
|
||||
LOG_RULE_WARNING("'device' link may not be available in future kernels; please fix");
|
||||
if (strstr(attr, "../") != NULL)
|
||||
LOG_RULE_WARNING("direct reference to parent sysfs directory, may break in future kernels; please fix");
|
||||
if (strstr(attr, "../"))
|
||||
LOG_RULE_WARNING("Direct reference to parent sysfs directory, may break in future kernels; please fix");
|
||||
rule_add_key(&rule_tmp, TK_M_ATTRS, op, value, attr);
|
||||
|
||||
} else if (streq(key, "TAGS")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_TAGS, op, value, NULL);
|
||||
|
||||
} else if (startswith(key, "ENV{")) {
|
||||
attr = get_key_attribute(key + STRLEN("ENV"));
|
||||
if (attr == NULL)
|
||||
LOG_AND_RETURN("error parsing %s attribute", "ENV");
|
||||
if (!attr)
|
||||
LOG_AND_RETURN("Failed to parse %s attribute", "ENV");
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", "ENV");
|
||||
LOG_AND_RETURN("Invalid %s operation", "ENV");
|
||||
|
||||
if (op < OP_MATCH_MAX)
|
||||
rule_add_key(&rule_tmp, TK_M_ENV, op, value, attr);
|
||||
|
@ -1188,7 +1187,7 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
"DEVLINKS",
|
||||
"DEVPATH",
|
||||
"TAGS"))
|
||||
LOG_AND_RETURN("invalid ENV attribute, '%s' cannot be set", attr);
|
||||
LOG_AND_RETURN("Invalid ENV attribute, '%s' cannot be set", attr);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_A_ENV, op, value, attr);
|
||||
}
|
||||
|
@ -1201,24 +1200,24 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
} else if (streq(key, "PROGRAM")) {
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_PROGRAM, op, value, NULL);
|
||||
|
||||
} else if (streq(key, "RESULT")) {
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_M_RESULT, op, value, NULL);
|
||||
|
||||
} else if (startswith(key, "IMPORT")) {
|
||||
attr = get_key_attribute(key + STRLEN("IMPORT"));
|
||||
if (attr == NULL) {
|
||||
LOG_RULE_WARNING("ignoring IMPORT{} with missing type");
|
||||
if (!attr) {
|
||||
LOG_RULE_WARNING("Ignoring IMPORT{} with missing type");
|
||||
continue;
|
||||
}
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", "IMPORT");
|
||||
LOG_AND_RETURN("Invalid %s operation", "IMPORT");
|
||||
|
||||
if (streq(attr, "program")) {
|
||||
/* find known built-in command */
|
||||
|
@ -1248,16 +1247,16 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
else if (streq(attr, "parent"))
|
||||
rule_add_key(&rule_tmp, TK_M_IMPORT_PARENT, op, value, NULL);
|
||||
else
|
||||
LOG_RULE_ERROR("ignoring unknown %s{} type '%s'", "IMPORT", attr);
|
||||
LOG_RULE_ERROR("Ignoring unknown %s{} type '%s'", "IMPORT", attr);
|
||||
|
||||
} else if (startswith(key, "TEST")) {
|
||||
mode_t mode = 0;
|
||||
|
||||
if (op > OP_MATCH_MAX)
|
||||
LOG_AND_RETURN("invalid %s operation", "TEST");
|
||||
LOG_AND_RETURN("Invalid %s operation", "TEST");
|
||||
|
||||
attr = get_key_attribute(key + STRLEN("TEST"));
|
||||
if (attr != NULL) {
|
||||
if (attr) {
|
||||
mode = strtol(attr, NULL, 8);
|
||||
rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode);
|
||||
} else
|
||||
|
@ -1265,10 +1264,10 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
} else if (startswith(key, "RUN")) {
|
||||
attr = get_key_attribute(key + STRLEN("RUN"));
|
||||
if (attr == NULL)
|
||||
if (!attr)
|
||||
attr = "program";
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", "RUN");
|
||||
LOG_AND_RETURN("Invalid %s operation", "RUN");
|
||||
|
||||
if (streq(attr, "builtin")) {
|
||||
const enum udev_builtin_cmd cmd = udev_builtin_lookup(value);
|
||||
|
@ -1282,23 +1281,23 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
rule_add_key(&rule_tmp, TK_A_RUN_PROGRAM, op, value, &cmd);
|
||||
} else
|
||||
LOG_RULE_ERROR("ignoring unknown %s{} type '%s'", "RUN", attr);
|
||||
LOG_RULE_ERROR("Ignoring unknown %s{} type '%s'", "RUN", attr);
|
||||
|
||||
} else if (streq(key, "LABEL")) {
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_tmp.rule.rule.label_off = rules_add_string(rules, value);
|
||||
|
||||
} else if (streq(key, "GOTO")) {
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
rule_add_key(&rule_tmp, TK_A_GOTO, 0, value, NULL);
|
||||
|
||||
} else if (startswith(key, "NAME")) {
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
if (op < OP_MATCH_MAX)
|
||||
rule_add_key(&rule_tmp, TK_M_NAME, op, value, NULL);
|
||||
|
@ -1317,7 +1316,7 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
|
||||
} else if (streq(key, "SYMLINK")) {
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
if (op < OP_MATCH_MAX)
|
||||
rule_add_key(&rule_tmp, TK_M_DEVLINK, op, value, NULL);
|
||||
|
@ -1330,12 +1329,12 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
char *endptr;
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
uid = strtoul(value, &endptr, 10);
|
||||
if (endptr[0] == '\0')
|
||||
rule_add_key(&rule_tmp, TK_A_OWNER_ID, op, NULL, &uid);
|
||||
else if (rules->resolve_name_timing == RESOLVE_NAME_EARLY && strchr("$%", value[0]) == NULL) {
|
||||
else if (rules->resolve_name_timing == RESOLVE_NAME_EARLY && !strchr("$%", value[0])) {
|
||||
uid = add_uid(rules, value);
|
||||
rule_add_key(&rule_tmp, TK_A_OWNER_ID, op, NULL, &uid);
|
||||
} else if (rules->resolve_name_timing != RESOLVE_NAME_NEVER)
|
||||
|
@ -1348,12 +1347,12 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
char *endptr;
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
gid = strtoul(value, &endptr, 10);
|
||||
if (endptr[0] == '\0')
|
||||
rule_add_key(&rule_tmp, TK_A_GROUP_ID, op, NULL, &gid);
|
||||
else if ((rules->resolve_name_timing == RESOLVE_NAME_EARLY) && strchr("$%", value[0]) == NULL) {
|
||||
else if ((rules->resolve_name_timing == RESOLVE_NAME_EARLY) && !strchr("$%", value[0])) {
|
||||
gid = add_gid(rules, value);
|
||||
rule_add_key(&rule_tmp, TK_A_GROUP_ID, op, NULL, &gid);
|
||||
} else if (rules->resolve_name_timing != RESOLVE_NAME_NEVER)
|
||||
|
@ -1366,7 +1365,7 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
char *endptr;
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
mode = strtol(value, &endptr, 8);
|
||||
if (endptr[0] == '\0')
|
||||
|
@ -1379,17 +1378,17 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
const char *pos;
|
||||
|
||||
if (op == OP_REMOVE)
|
||||
LOG_AND_RETURN("invalid %s operation", key);
|
||||
LOG_AND_RETURN("Invalid %s operation", key);
|
||||
|
||||
pos = strstr(value, "link_priority=");
|
||||
if (pos != NULL) {
|
||||
if (pos) {
|
||||
int prio = atoi(pos + STRLEN("link_priority="));
|
||||
|
||||
rule_add_key(&rule_tmp, TK_A_DEVLINK_PRIO, op, NULL, &prio);
|
||||
}
|
||||
|
||||
pos = strstr(value, "string_escape=");
|
||||
if (pos != NULL) {
|
||||
if (pos) {
|
||||
pos += STRLEN("string_escape=");
|
||||
if (startswith(pos, "none"))
|
||||
rule_add_key(&rule_tmp, TK_A_STRING_ESCAPE_NONE, op, NULL, NULL);
|
||||
|
@ -1398,7 +1397,7 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
}
|
||||
|
||||
pos = strstr(value, "db_persist");
|
||||
if (pos != NULL)
|
||||
if (pos)
|
||||
rule_add_key(&rule_tmp, TK_A_DB_PERSIST, op, NULL, NULL);
|
||||
|
||||
pos = strstr(value, "nowatch");
|
||||
|
@ -1413,20 +1412,20 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
}
|
||||
|
||||
pos = strstr(value, "static_node=");
|
||||
if (pos != NULL) {
|
||||
if (pos) {
|
||||
pos += STRLEN("static_node=");
|
||||
rule_add_key(&rule_tmp, TK_A_STATIC_NODE, op, pos, NULL);
|
||||
rule_tmp.rule.rule.has_static_node = true;
|
||||
}
|
||||
|
||||
} else
|
||||
LOG_AND_RETURN("unknown key '%s'", key);
|
||||
LOG_AND_RETURN("Unknown key '%s'", key);
|
||||
}
|
||||
|
||||
/* add rule token and sort tokens */
|
||||
rule_tmp.rule.rule.token_count = 1 + rule_tmp.token_cur;
|
||||
if (add_token(rules, &rule_tmp.rule) != 0 || sort_token(rules, &rule_tmp) != 0)
|
||||
LOG_RULE_ERROR("failed to add rule token");
|
||||
LOG_RULE_ERROR("Failed to add rule token");
|
||||
}
|
||||
|
||||
static int parse_file(struct udev_rules *rules, const char *filename) {
|
||||
|
@ -1454,7 +1453,7 @@ static int parse_file(struct udev_rules *rules, const char *filename) {
|
|||
first_token = rules->token_cur;
|
||||
filename_off = rules_add_string(rules, filename);
|
||||
|
||||
while (fgets(line, sizeof(line), f) != NULL) {
|
||||
while (fgets(line, sizeof(line), f)) {
|
||||
char *key;
|
||||
size_t len;
|
||||
|
||||
|
@ -1474,7 +1473,7 @@ static int parse_file(struct udev_rules *rules, const char *filename) {
|
|||
|
||||
/* continue reading if backslash+newline is found */
|
||||
while (line[len-2] == '\\') {
|
||||
if (fgets(&line[len-2], (sizeof(line)-len)+2, f) == NULL)
|
||||
if (!fgets(&line[len-2], (sizeof(line)-len)+2, f))
|
||||
break;
|
||||
if (strlen(&line[len-2]) < 2)
|
||||
break;
|
||||
|
@ -1483,7 +1482,7 @@ static int parse_file(struct udev_rules *rules, const char *filename) {
|
|||
}
|
||||
|
||||
if (len+1 >= sizeof(line)) {
|
||||
log_error("line too long '%s':%u, ignored", filename, line_nr);
|
||||
log_error("Line too long '%s':%u, ignored", filename, line_nr);
|
||||
continue;
|
||||
}
|
||||
add_rule(rules, key, filename, filename_off, line_nr);
|
||||
|
@ -1530,20 +1529,20 @@ struct udev_rules *udev_rules_new(ResolveNameTiming resolve_name_timing) {
|
|||
|
||||
/* init token array and string buffer */
|
||||
rules->tokens = malloc_multiply(PREALLOC_TOKEN, sizeof(struct token));
|
||||
if (rules->tokens == NULL)
|
||||
return udev_rules_unref(rules);
|
||||
if (!rules->tokens)
|
||||
return udev_rules_free(rules);
|
||||
rules->token_max = PREALLOC_TOKEN;
|
||||
|
||||
rules->strbuf = strbuf_new();
|
||||
if (!rules->strbuf)
|
||||
return udev_rules_unref(rules);
|
||||
return udev_rules_free(rules);
|
||||
|
||||
udev_rules_check_timestamp(rules);
|
||||
|
||||
r = conf_files_list_strv(&files, ".rules", NULL, 0, rules_dirs);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "failed to enumerate rules files: %m");
|
||||
return udev_rules_unref(rules);
|
||||
log_error_errno(r, "Failed to enumerate rules files: %m");
|
||||
return udev_rules_free(rules);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1561,7 +1560,7 @@ struct udev_rules *udev_rules_new(ResolveNameTiming resolve_name_timing) {
|
|||
memzero(&end_token, sizeof(struct token));
|
||||
end_token.type = TK_END;
|
||||
add_token(rules, &end_token);
|
||||
log_debug("rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings",
|
||||
log_debug("Rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings",
|
||||
rules->token_max * sizeof(struct token), rules->token_max, sizeof(struct token), rules->strbuf->len);
|
||||
|
||||
/* cleanup temporary strbuf data */
|
||||
|
@ -1582,8 +1581,8 @@ struct udev_rules *udev_rules_new(ResolveNameTiming resolve_name_timing) {
|
|||
return rules;
|
||||
}
|
||||
|
||||
struct udev_rules *udev_rules_unref(struct udev_rules *rules) {
|
||||
if (rules == NULL)
|
||||
struct udev_rules *udev_rules_free(struct udev_rules *rules) {
|
||||
if (!rules)
|
||||
return NULL;
|
||||
free(rules->tokens);
|
||||
strbuf_cleanup(rules->strbuf);
|
||||
|
@ -1604,7 +1603,7 @@ static int match_key(struct udev_rules *rules, struct token *token, const char *
|
|||
char *pos;
|
||||
bool match = false;
|
||||
|
||||
if (val == NULL)
|
||||
if (!val)
|
||||
val = "";
|
||||
|
||||
switch (token->key.glob) {
|
||||
|
@ -1625,7 +1624,7 @@ static int match_key(struct udev_rules *rules, struct token *token, const char *
|
|||
const char *next;
|
||||
|
||||
next = strchr(s, '|');
|
||||
if (next != NULL) {
|
||||
if (next) {
|
||||
size_t matchlen = (size_t)(next - s);
|
||||
|
||||
match = (matchlen == len && strneq(s, val, matchlen));
|
||||
|
@ -1645,9 +1644,9 @@ static int match_key(struct udev_rules *rules, struct token *token, const char *
|
|||
|
||||
strscpy(value, sizeof(value), rules_str(rules, token->key.value_off));
|
||||
key_value = value;
|
||||
while (key_value != NULL) {
|
||||
while (key_value) {
|
||||
pos = strchr(key_value, '|');
|
||||
if (pos != NULL) {
|
||||
if (pos) {
|
||||
pos[0] = '\0';
|
||||
pos = &pos[1];
|
||||
}
|
||||
|
@ -1973,7 +1972,7 @@ int udev_rules_apply_to_event(
|
|||
if (IN_SET(esc, ESCAPE_UNSET, ESCAPE_REPLACE)) {
|
||||
count = util_replace_chars(result, UDEV_ALLOWED_CHARS_INPUT);
|
||||
if (count > 0)
|
||||
log_debug("%i character(s) replaced" , count);
|
||||
log_debug("Replaced %i character(s)" , count);
|
||||
}
|
||||
event->program_result = strdup(result);
|
||||
if (cur->key.op == OP_NOMATCH)
|
||||
|
@ -2281,7 +2280,7 @@ int udev_rules_apply_to_event(
|
|||
(*p >= '0' && *p <= '9') ||
|
||||
IN_SET(*p, '-', '_'))
|
||||
continue;
|
||||
log_error("ignoring invalid tag name '%s'", tag);
|
||||
log_error("Ignoring invalid tag name '%s'", tag);
|
||||
break;
|
||||
}
|
||||
if (cur->key.op == OP_REMOVE)
|
||||
|
@ -2304,7 +2303,7 @@ int udev_rules_apply_to_event(
|
|||
if (IN_SET(esc, ESCAPE_UNSET, ESCAPE_REPLACE)) {
|
||||
count = util_replace_chars(name_str, "/");
|
||||
if (count > 0)
|
||||
log_debug("%i character(s) replaced", count);
|
||||
log_debug("Replaced %i character(s)", count);
|
||||
}
|
||||
if (sd_device_get_devnum(dev, NULL) >= 0 &&
|
||||
(sd_device_get_devname(dev, &val) < 0 ||
|
||||
|
@ -2344,7 +2343,7 @@ int udev_rules_apply_to_event(
|
|||
else if (esc == ESCAPE_REPLACE)
|
||||
count = util_replace_chars(temp, "/");
|
||||
if (count > 0)
|
||||
log_debug("%i character(s) replaced" , count);
|
||||
log_debug("Replaced %i character(s)" , count);
|
||||
pos = temp;
|
||||
while (isspace(pos[0]))
|
||||
pos++;
|
||||
|
@ -2384,10 +2383,10 @@ int udev_rules_apply_to_event(
|
|||
rules_str(rules, rule->rule.filename_off),
|
||||
rule->rule.filename_line);
|
||||
f = fopen(attr, "we");
|
||||
if (f == NULL)
|
||||
log_error_errno(errno, "error opening ATTR{%s} for writing: %m", attr);
|
||||
if (!f)
|
||||
log_error_errno(errno, "Failed to open ATTR{%s} for writing: %m", attr);
|
||||
else if (fprintf(f, "%s", value) <= 0)
|
||||
log_error_errno(errno, "error writing ATTR{%s}: %m", attr);
|
||||
log_error_errno(errno, "Failed to write ATTR{%s}: %m", attr);
|
||||
break;
|
||||
}
|
||||
case TK_A_SYSCTL: {
|
||||
|
@ -2400,7 +2399,7 @@ int udev_rules_apply_to_event(
|
|||
rules_str(rules, rule->rule.filename_off), rule->rule.filename_line);
|
||||
r = sysctl_write(filename, value);
|
||||
if (r < 0)
|
||||
log_error_errno(r, "error writing SYSCTL{%s}='%s': %m", filename, value);
|
||||
log_error_errno(r, "Failed to write SYSCTL{%s}='%s': %m", filename, value);
|
||||
break;
|
||||
}
|
||||
case TK_A_RUN_BUILTIN:
|
||||
|
@ -2446,7 +2445,7 @@ int udev_rules_apply_to_event(
|
|||
case TK_M_PARENTS_MAX:
|
||||
case TK_M_MAX:
|
||||
case TK_UNSET:
|
||||
log_error("wrong type %u", cur->type);
|
||||
log_error("Wrong type %u", cur->type);
|
||||
goto nomatch;
|
||||
}
|
||||
|
||||
|
@ -2472,7 +2471,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
|
|||
_cleanup_free_ char *path = NULL;
|
||||
int r;
|
||||
|
||||
if (rules->tokens == NULL)
|
||||
if (!rules->tokens)
|
||||
return 0;
|
||||
|
||||
cur = &rules->tokens[0];
|
||||
|
@ -2515,7 +2514,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
|
|||
|
||||
/* we assure, that the permissions tokens are sorted before the static token */
|
||||
|
||||
if (mode == 0 && uid == 0 && gid == 0 && tags == NULL)
|
||||
if (mode == 0 && uid == 0 && gid == 0 && !tags)
|
||||
goto next;
|
||||
|
||||
strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
|
||||
|
@ -2532,14 +2531,14 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
|
|||
strscpyl(tags_dir, sizeof(tags_dir), "/run/udev/static_node-tags/", *t, "/", NULL);
|
||||
r = mkdir_p(tags_dir, 0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "failed to create %s: %m", tags_dir);
|
||||
return log_error_errno(r, "Failed to create %s: %m", tags_dir);
|
||||
|
||||
unescaped_filename = xescape(rules_str(rules, cur->key.value_off), "/.");
|
||||
|
||||
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
|
||||
r = symlink(device_node, tag_symlink);
|
||||
if (r < 0 && errno != EEXIST)
|
||||
return log_error_errno(errno, "failed to create symlink %s -> %s: %m",
|
||||
return log_error_errno(errno, "Failed to create symlink %s -> %s: %m",
|
||||
tag_symlink, device_node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ struct udev_event {
|
|||
/* udev-rules.c */
|
||||
struct udev_rules;
|
||||
struct udev_rules *udev_rules_new(ResolveNameTiming resolve_name_timing);
|
||||
struct udev_rules *udev_rules_unref(struct udev_rules *rules);
|
||||
struct udev_rules *udev_rules_free(struct udev_rules *rules);
|
||||
bool udev_rules_check_timestamp(struct udev_rules *rules);
|
||||
int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event,
|
||||
usec_t timeout_usec,
|
||||
|
@ -77,4 +77,4 @@ void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec);
|
|||
|
||||
/* Cleanup functions */
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_free);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_free);
|
||||
|
|
|
@ -86,7 +86,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
int test_main(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(udev_rules_unrefp) struct udev_rules *rules = NULL;
|
||||
_cleanup_(udev_rules_freep) struct udev_rules *rules = NULL;
|
||||
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
|
||||
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
|
||||
const char *cmd, *key, *value;
|
||||
|
|
|
@ -310,7 +310,7 @@ static void manager_free(Manager *manager) {
|
|||
sd_netlink_unref(manager->rtnl);
|
||||
|
||||
hashmap_free_free_free(manager->properties);
|
||||
udev_rules_unref(manager->rules);
|
||||
udev_rules_free(manager->rules);
|
||||
|
||||
safe_close(manager->fd_inotify);
|
||||
safe_close_pair(manager->worker_watch);
|
||||
|
@ -843,7 +843,7 @@ static void manager_reload(Manager *manager) {
|
|||
"STATUS=Flushing configuration...");
|
||||
|
||||
manager_kill_workers(manager);
|
||||
manager->rules = udev_rules_unref(manager->rules);
|
||||
manager->rules = udev_rules_free(manager->rules);
|
||||
udev_builtin_exit();
|
||||
|
||||
sd_notifyf(false,
|
||||
|
|
Loading…
Reference in a new issue