aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fuzz/fuzz-udev-rules.c2
-rw-r--r--src/test/test-udev.c2
-rw-r--r--src/udev/udev-event.c4
-rw-r--r--src/udev/udev-rules.c48
-rw-r--r--src/udev/udev.h17
-rw-r--r--src/udev/udevadm-test.c2
-rw-r--r--src/udev/udevd.c2
7 files changed, 39 insertions, 38 deletions
diff --git a/src/fuzz/fuzz-udev-rules.c b/src/fuzz/fuzz-udev-rules.c
index 42f0fa0b9..e894fa8d2 100644
--- a/src/fuzz/fuzz-udev-rules.c
+++ b/src/fuzz/fuzz-udev-rules.c
@@ -74,7 +74,7 @@ static int cleanup_fake_filesystems(const char *runtime_dir) {
}
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
- _cleanup_(udev_rules_freep) struct udev_rules *rules = NULL;
+ _cleanup_(udev_rules_freep) UdevRules *rules = NULL;
_cleanup_(rm_rf_physical_and_freep) char *runtime_dir = NULL;
FILE *f = NULL;
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index 9165fad73..74450e132 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -55,7 +55,7 @@ static int fake_filesystems(void) {
}
static int run(int argc, char *argv[]) {
- _cleanup_(udev_rules_freep) struct udev_rules *rules = NULL;
+ _cleanup_(udev_rules_freep) UdevRules *rules = NULL;
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
const char *devpath, *devname, *action;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index bb3e1b9f2..14b4b51b7 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -780,7 +780,7 @@ static void event_execute_rules_on_remove(
struct udev_event *event,
usec_t timeout_usec,
Hashmap *properties_list,
- struct udev_rules *rules) {
+ UdevRules *rules) {
sd_device *dev = event->dev;
int r;
@@ -809,7 +809,7 @@ static void event_execute_rules_on_remove(
int udev_event_execute_rules(struct udev_event *event,
usec_t timeout_usec,
Hashmap *properties_list,
- struct udev_rules *rules) {
+ UdevRules *rules) {
sd_device *dev = event->dev;
const char *subsystem, *action;
int r;
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 4e516d7fc..97dddfa3e 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -57,7 +57,7 @@ static const char* const rules_dirs[] = {
NULL
};
-struct udev_rules {
+struct UdevRules {
usec_t dirs_ts_usec;
ResolveNameTiming resolve_name_timing;
@@ -78,11 +78,11 @@ struct udev_rules {
unsigned gids_max;
};
-static char *rules_str(struct udev_rules *rules, unsigned off) {
+static char *rules_str(UdevRules *rules, unsigned off) {
return rules->strbuf->buf + off;
}
-static unsigned rules_add_string(struct udev_rules *rules, const char *s) {
+static unsigned rules_add_string(UdevRules *rules, const char *s) {
return strbuf_add_string(rules->strbuf, s, strlen(s));
}
@@ -216,7 +216,7 @@ struct token {
#define MAX_TK 64
struct rule_tmp {
- struct udev_rules *rules;
+ UdevRules *rules;
struct token rule;
struct token token[MAX_TK];
unsigned token_cur;
@@ -318,7 +318,7 @@ static const char *token_str(enum token_type type) {
return token_strs[type];
}
-static void dump_token(struct udev_rules *rules, struct token *token) {
+static void dump_token(UdevRules *rules, struct token *token) {
enum token_type type = token->type;
enum operation_type op = token->key.op;
enum string_glob_type glob = token->key.glob;
@@ -429,7 +429,7 @@ static void dump_token(struct udev_rules *rules, struct token *token) {
}
}
-static void dump_rules(struct udev_rules *rules) {
+static void dump_rules(UdevRules *rules) {
unsigned i;
log_debug("Dumping %u (%zu bytes) tokens, %zu (%zu bytes) strings",
@@ -441,11 +441,11 @@ static void dump_rules(struct udev_rules *rules) {
dump_token(rules, &rules->tokens[i]);
}
#else
-static inline void dump_token(struct udev_rules *rules, struct token *token) {}
-static inline void dump_rules(struct udev_rules *rules) {}
+static inline void dump_token(UdevRules *rules, struct token *token) {}
+static inline void dump_rules(UdevRules *rules) {}
#endif /* ENABLE_DEBUG_UDEV */
-static int add_token(struct udev_rules *rules, struct token *token) {
+static int add_token(UdevRules *rules, struct token *token) {
/* grow buffer if needed */
if (rules->token_cur+1 >= rules->token_max) {
struct token *tokens;
@@ -474,7 +474,7 @@ static void log_unknown_owner(sd_device *dev, int error, const char *entity, con
log_device_error_errno(dev, error, "Failed to resolve %s '%s': %m", entity, owner);
}
-static uid_t add_uid(struct udev_rules *rules, const char *owner) {
+static uid_t add_uid(UdevRules *rules, const char *owner) {
unsigned i;
uid_t uid = 0;
unsigned off;
@@ -517,7 +517,7 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner) {
return uid;
}
-static gid_t add_gid(struct udev_rules *rules, const char *group) {
+static gid_t add_gid(UdevRules *rules, const char *group) {
unsigned i;
gid_t gid = 0;
unsigned off;
@@ -970,7 +970,7 @@ static void rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
rule_tmp->token_cur++;
}
-static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) {
+static int sort_token(UdevRules *rules, struct rule_tmp *rule_tmp) {
unsigned i;
unsigned start = 0;
unsigned end = rule_tmp->token_cur;
@@ -1010,7 +1010,7 @@ static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) {
#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,
+static void add_rule(UdevRules *rules, char *line,
const char *filename, unsigned filename_off, unsigned lineno) {
char *linepos;
const char *attr;
@@ -1429,7 +1429,7 @@ static void add_rule(struct udev_rules *rules, char *line,
LOG_RULE_ERROR("Failed to add rule token");
}
-static int parse_file(struct udev_rules *rules, const char *filename) {
+static int parse_file(UdevRules *rules, const char *filename) {
_cleanup_fclose_ FILE *f = NULL;
unsigned first_token;
unsigned filename_off;
@@ -1512,19 +1512,19 @@ static int parse_file(struct udev_rules *rules, const char *filename) {
return 0;
}
-int udev_rules_new(struct udev_rules **ret_rules, ResolveNameTiming resolve_name_timing) {
- _cleanup_(udev_rules_freep) struct udev_rules *rules = NULL;
+int udev_rules_new(UdevRules **ret_rules, ResolveNameTiming resolve_name_timing) {
+ _cleanup_(udev_rules_freep) UdevRules *rules = NULL;
_cleanup_strv_free_ char **files = NULL;
char **f;
int r;
assert(resolve_name_timing >= 0 && resolve_name_timing < _RESOLVE_NAME_TIMING_MAX);
- rules = new(struct udev_rules, 1);
+ rules = new(UdevRules, 1);
if (!rules)
return -ENOMEM;
- *rules = (struct udev_rules) {
+ *rules = (UdevRules) {
.resolve_name_timing = resolve_name_timing,
};
@@ -1578,7 +1578,7 @@ int udev_rules_new(struct udev_rules **ret_rules, ResolveNameTiming resolve_name
return 0;
}
-struct udev_rules *udev_rules_free(struct udev_rules *rules) {
+UdevRules *udev_rules_free(UdevRules *rules) {
if (!rules)
return NULL;
free(rules->tokens);
@@ -1588,14 +1588,14 @@ struct udev_rules *udev_rules_free(struct udev_rules *rules) {
return mfree(rules);
}
-bool udev_rules_check_timestamp(struct udev_rules *rules) {
+bool udev_rules_check_timestamp(UdevRules *rules) {
if (!rules)
return false;
return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
}
-static int match_key(struct udev_rules *rules, struct token *token, const char *val) {
+static int match_key(UdevRules *rules, struct token *token, const char *val) {
char *key_value = rules_str(rules, token->key.value_off);
char *pos;
bool match = false;
@@ -1668,7 +1668,7 @@ static int match_key(struct udev_rules *rules, struct token *token, const char *
return -1;
}
-static int match_attr(struct udev_rules *rules, sd_device *dev, struct udev_event *event, struct token *cur) {
+static int match_attr(UdevRules *rules, sd_device *dev, struct udev_event *event, struct token *cur) {
char nbuf[UTIL_NAME_SIZE], vbuf[UTIL_NAME_SIZE];
const char *name, *value;
size_t len;
@@ -1720,7 +1720,7 @@ enum escape_type {
};
int udev_rules_apply_to_event(
- struct udev_rules *rules,
+ UdevRules *rules,
struct udev_event *event,
usec_t timeout_usec,
Hashmap *properties_list) {
@@ -2452,7 +2452,7 @@ int udev_rules_apply_to_event(
return 0;
}
-int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
+int udev_rules_apply_static_dev_perms(UdevRules *rules) {
struct token *cur;
struct token *rule;
uid_t uid = 0;
diff --git a/src/udev/udev.h b/src/udev/udev.h
index 67e05e132..b36a8f121 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -46,15 +46,16 @@ struct udev_event {
};
/* udev-rules.c */
-struct udev_rules;
-int udev_rules_new(struct udev_rules **ret_rules, ResolveNameTiming resolve_name_timing);
-struct udev_rules *udev_rules_free(struct udev_rules *rules);
+typedef struct UdevRules UdevRules;
-bool udev_rules_check_timestamp(struct udev_rules *rules);
-int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event,
+int udev_rules_new(UdevRules **ret_rules, ResolveNameTiming resolve_name_timing);
+UdevRules *udev_rules_free(UdevRules *rules);
+
+bool udev_rules_check_timestamp(UdevRules *rules);
+int udev_rules_apply_to_event(UdevRules *rules, struct udev_event *event,
usec_t timeout_usec,
Hashmap *properties_list);
-int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
+int udev_rules_apply_static_dev_perms(UdevRules *rules);
static inline usec_t udev_warn_timeout(usec_t timeout_usec) {
return DIV_ROUND_UP(timeout_usec, 3);
@@ -73,9 +74,9 @@ int udev_event_spawn(struct udev_event *event,
int udev_event_execute_rules(struct udev_event *event,
usec_t timeout_usec,
Hashmap *properties_list,
- struct udev_rules *rules);
+ UdevRules *rules);
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_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(UdevRules*, udev_rules_free);
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index d649525dd..47f055c7f 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -86,7 +86,7 @@ static int parse_argv(int argc, char *argv[]) {
}
int test_main(int argc, char *argv[], void *userdata) {
- _cleanup_(udev_rules_freep) struct udev_rules *rules = NULL;
+ _cleanup_(udev_rules_freep) UdevRules *rules = NULL;
_cleanup_(udev_event_freep) struct udev_event *event = NULL;
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
const char *cmd, *key, *value;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 44973a34b..863082941 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -81,7 +81,7 @@ typedef struct Manager {
const char *cgroup;
pid_t pid; /* the process that originally allocated the manager object */
- struct udev_rules *rules;
+ UdevRules *rules;
Hashmap *properties;
sd_netlink *rtnl;