diff options
Diffstat (limited to 'src/udev/udev-rules.c')
-rw-r--r-- | src/udev/udev-rules.c | 78 |
1 files changed, 26 insertions, 52 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 4be7f020aa..ef79f8ea5d 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -221,8 +221,7 @@ struct rule_tmp { }; #ifdef DEBUG -static const char *operation_str(enum operation_type type) -{ +static const char *operation_str(enum operation_type type) { static const char *operation_strs[] = { [OP_UNSET] = "UNSET", [OP_MATCH] = "match", @@ -237,8 +236,7 @@ static const char *operation_str(enum operation_type type) return operation_strs[type]; } -static const char *string_glob_str(enum string_glob_type type) -{ +static const char *string_glob_str(enum string_glob_type type) { static const char *string_glob_strs[] = { [GL_UNSET] = "UNSET", [GL_PLAIN] = "plain", @@ -251,8 +249,7 @@ static const char *string_glob_str(enum string_glob_type type) return string_glob_strs[type]; } -static const char *token_str(enum token_type type) -{ +static const char *token_str(enum token_type type) { static const char *token_strs[] = { [TK_UNSET] = "UNSET", [TK_RULE] = "RULE", @@ -316,8 +313,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(struct udev_rules *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; @@ -426,8 +422,7 @@ static void dump_token(struct udev_rules *rules, struct token *token) } } -static void dump_rules(struct udev_rules *rules) -{ +static void dump_rules(struct udev_rules *rules) { unsigned int i; log_debug("dumping %u (%zu bytes) tokens, %u (%zu bytes) strings", @@ -443,8 +438,7 @@ static inline void dump_token(struct udev_rules *rules, struct token *token) {} static inline void dump_rules(struct udev_rules *rules) {} #endif /* DEBUG */ -static int add_token(struct udev_rules *rules, struct token *token) -{ +static int add_token(struct udev_rules *rules, struct token *token) { /* grow buffer if needed */ if (rules->token_cur+1 >= rules->token_max) { struct token *tokens; @@ -466,8 +460,7 @@ static int add_token(struct udev_rules *rules, struct token *token) return 0; } -static uid_t add_uid(struct udev_rules *rules, const char *owner) -{ +static uid_t add_uid(struct udev_rules *rules, const char *owner) { unsigned int i; uid_t uid; unsigned int off; @@ -507,8 +500,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(struct udev_rules *rules, const char *group) { unsigned int i; gid_t gid; unsigned int off; @@ -548,8 +540,7 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) return gid; } -static int import_property_from_string(struct udev_device *dev, char *line) -{ +static int import_property_from_string(struct udev_device *dev, char *line) { char *key; char *val; size_t len; @@ -612,8 +603,7 @@ static int import_property_from_string(struct udev_device *dev, char *line) return 0; } -static int import_file_into_properties(struct udev_device *dev, const char *filename) -{ +static int import_file_into_properties(struct udev_device *dev, const char *filename) { FILE *f; char line[UTIL_LINE_SIZE]; @@ -655,8 +645,7 @@ static int import_program_into_properties(struct udev_event *event, return 0; } -static int import_parent_into_properties(struct udev_device *dev, const char *filter) -{ +static int import_parent_into_properties(struct udev_device *dev, const char *filter) { struct udev_device *dev_parent; struct udev_list_entry *list_entry; @@ -681,8 +670,7 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi } #define WAIT_LOOP_PER_SECOND 50 -static int wait_for_file(struct udev_device *dev, const char *file, int timeout) -{ +static int wait_for_file(struct udev_device *dev, const char *file, int timeout) { char filepath[UTIL_PATH_SIZE]; char devicepath[UTIL_PATH_SIZE]; struct stat stats; @@ -716,8 +704,7 @@ static int wait_for_file(struct udev_device *dev, const char *file, int timeout) return -1; } -static int attr_subst_subdir(char *attr, size_t len) -{ +static int attr_subst_subdir(char *attr, size_t len) { bool found = false; if (strstr(attr, "/*/")) { @@ -754,8 +741,7 @@ static int attr_subst_subdir(char *attr, size_t len) return found; } -static int get_key(struct udev *udev, char **line, char **key, enum operation_type *op, char **value) -{ +static int get_key(struct udev *udev, char **line, char **key, enum operation_type *op, char **value) { char *linepos; char *temp; @@ -842,8 +828,7 @@ static int get_key(struct udev *udev, char **line, char **key, enum operation_ty } /* extract possible KEY{attr} */ -static const char *get_key_attribute(struct udev *udev, char *str) -{ +static const char *get_key_attribute(struct udev *udev, char *str) { char *pos; char *attr; @@ -863,8 +848,7 @@ static const char *get_key_attribute(struct udev *udev, char *str) static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type, enum operation_type op, - const char *value, const void *data) -{ + const char *value, const void *data) { struct token *token = &rule_tmp->token[rule_tmp->token_cur]; const char *attr = NULL; @@ -1005,8 +989,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type, return 0; } -static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) -{ +static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) { unsigned int i; unsigned int start = 0; unsigned int end = rule_tmp->token_cur; @@ -1041,8 +1024,7 @@ static int sort_token(struct udev_rules *rules, struct rule_tmp *rule_tmp) } static int add_rule(struct udev_rules *rules, char *line, - const char *filename, unsigned int filename_off, unsigned int lineno) -{ + const char *filename, unsigned int filename_off, unsigned int lineno) { char *linepos; const char *attr; struct rule_tmp rule_tmp; @@ -1513,8 +1495,7 @@ invalid: return -1; } -static int parse_file(struct udev_rules *rules, const char *filename) -{ +static int parse_file(struct udev_rules *rules, const char *filename) { FILE *f; unsigned int first_token; unsigned int filename_off; @@ -1598,8 +1579,7 @@ static int parse_file(struct udev_rules *rules, const char *filename) return 0; } -struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) -{ +struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) { struct udev_rules *rules; struct udev_list file_list; struct token end_token; @@ -1669,8 +1649,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) return rules; } -struct udev_rules *udev_rules_unref(struct udev_rules *rules) -{ +struct udev_rules *udev_rules_unref(struct udev_rules *rules) { if (rules == NULL) return NULL; free(rules->tokens); @@ -1681,16 +1660,14 @@ struct udev_rules *udev_rules_unref(struct udev_rules *rules) return NULL; } -bool udev_rules_check_timestamp(struct udev_rules *rules) -{ +bool udev_rules_check_timestamp(struct udev_rules *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(struct udev_rules *rules, struct token *token, const char *val) { char *key_value = rules_str(rules, token->key.value_off); char *pos; bool match = false; @@ -1763,8 +1740,7 @@ static int match_key(struct udev_rules *rules, struct token *token, const char * return -1; } -static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur) -{ +static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur) { const char *name; char nbuf[UTIL_NAME_SIZE]; const char *value; @@ -1820,8 +1796,7 @@ enum escape_type { #ifdef ENABLE_RULE_GENERATOR /* function to return the count of rules that assign NAME= to a value matching arg#2 - returns 0,1 */ -int udev_rules_assigning_name_to(struct udev_rules *rules, const char *match_name) -{ +int udev_rules_assigning_name_to(struct udev_rules *rules, const char *match_name) { struct token *cur; struct token *rule; enum escape_type esc = ESCAPE_UNSET; @@ -2555,8 +2530,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, } } -int udev_rules_apply_static_dev_perms(struct udev_rules *rules) -{ +int udev_rules_apply_static_dev_perms(struct udev_rules *rules) { struct token *cur; struct token *rule; uid_t uid = 0; |