diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-07-18 15:56:03 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-07-18 15:56:03 +0200 |
commit | 282988c4f8a85c28468e6442e86efe51dc71cc93 (patch) | |
tree | fda0a6ba62adffd8f7c4762b9694ab77e4ea563f /udev_rules_parse.c | |
parent | 41dd741442ab496901c38f6cd38404bd954f1857 (diff) |
move default rules from /etc/udev/rules.d/ to /lib/udev/rules.d/
None of these rules is supposed to be changed by users, so move
them out of /etc. Custom rules, and automatically generated rules
stay in /etc. All rules are still processed in lexical order,
regardless which directory they live in.
Diffstat (limited to 'udev_rules_parse.c')
-rw-r--r-- | udev_rules_parse.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/udev_rules_parse.c b/udev_rules_parse.c index bdaf55bd48..999af3b85e 100644 --- a/udev_rules_parse.c +++ b/udev_rules_parse.c @@ -727,53 +727,53 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names) struct stat statbuf; char filename[PATH_MAX]; LIST_HEAD(name_list); - LIST_HEAD(dyn_list); + LIST_HEAD(sort_list); struct name_entry *name_loop, *name_tmp; - struct name_entry *dyn_loop, *dyn_tmp; + struct name_entry *sort_loop, *sort_tmp; int retval = 0; memset(rules, 0x00, sizeof(struct udev_rules)); rules->resolve_names = resolve_names; - /* read main config from single file or all files in a directory */ - if (stat(udev_rules_dir, &statbuf) != 0) - return -1; - if ((statbuf.st_mode & S_IFMT) != S_IFDIR) { - dbg("parse single rules file '%s'\n", udev_rules_dir); - name_list_add(&name_list, udev_rules_dir, 1); + if (udev_rules_dir[0] != '\0') { + /* custom rules location for testing */ + add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX); } else { - dbg("parse rules directory '%s'\n", udev_rules_dir); - retval = add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX); - } - - /* read dynamic rules directory */ - strlcpy(filename, udev_root, sizeof(filename)); - strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); - if (stat(filename, &statbuf) != 0) { - create_path(filename); - selinux_setfscreatecon(filename, NULL, S_IFDIR|0755); - mkdir(filename, 0755); - selinux_resetfscreatecon(); - } - add_matching_files(&dyn_list, filename, RULESFILE_SUFFIX); + /* read default rules */ + add_matching_files(&name_list, RULES_LIB_DIR, RULESFILE_SUFFIX); + + /* read user/custom rules */ + add_matching_files(&sort_list, RULES_ETC_DIR, RULESFILE_SUFFIX); + + /* read dynamic/temporary rules */ + strlcpy(filename, udev_root, sizeof(filename)); + strlcat(filename, "/"RULES_DYN_DIR, sizeof(filename)); + if (stat(filename, &statbuf) != 0) { + create_path(filename); + selinux_setfscreatecon(filename, NULL, S_IFDIR|0755); + mkdir(filename, 0755); + selinux_resetfscreatecon(); + } + add_matching_files(&sort_list, filename, RULESFILE_SUFFIX); - /* sort dynamic rules files by basename into list of files */ - list_for_each_entry_safe(dyn_loop, dyn_tmp, &dyn_list, node) { - const char *dyn_base = strrchr(dyn_loop->name, '/'); + /* sort all rules files by basename into list of files */ + list_for_each_entry_safe(sort_loop, sort_tmp, &sort_list, node) { + const char *sort_base = strrchr(sort_loop->name, '/'); - if (dyn_base == NULL) - continue; + if (sort_base == NULL) + continue; - list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) { - const char *name_base = strrchr(name_loop->name, '/'); + list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) { + const char *name_base = strrchr(name_loop->name, '/'); - if (name_base == NULL) - continue; + if (name_base == NULL) + continue; - if (strcmp(name_base, dyn_base) > 0) - break; + if (strcmp(name_base, sort_base) > 0) + break; + } + list_move_tail(&sort_loop->node, &name_loop->node); } - list_move_tail(&dyn_loop->node, &name_loop->node); } /* parse list of files */ |