chiark / gitweb /
rename config "filename" to "dir"
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 8 Dec 2006 08:48:53 +0000 (09:48 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 8 Dec 2006 08:48:53 +0000 (09:48 +0100)
Makefile
udev.h
udev_config.c
udev_rules.h
udev_rules_parse.c
udev_utils.c
udevd.c

index 947eaca..b3a5005 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -199,7 +199,7 @@ udev_version.h:
        $(Q) echo \#define UDEV_VERSION         \"$(VERSION)\" >> $@
        $(Q) echo \#define UDEV_ROOT            \"$(udevdir)\" >> $@
        $(Q) echo \#define UDEV_CONFIG_FILE     \"$(configdir)/udev.conf\" >> $@
-       $(Q) echo \#define UDEV_RULES_FILE      \"$(configdir)/rules.d\" >> $@
+       $(Q) echo \#define UDEV_RULES_DIR       \"$(configdir)/rules.d\" >> $@
 
 # man pages
 %.8 %.7: %.xml
diff --git a/udev.h b/udev.h
index d09c992..849de96 100644 (file)
--- a/udev.h
+++ b/udev.h
@@ -92,7 +92,7 @@ struct udevice {
 /* udev_config.c */
 extern char udev_root[PATH_SIZE];
 extern char udev_config_filename[PATH_SIZE];
-extern char udev_rules_filename[PATH_SIZE];
+extern char udev_rules_dir[PATH_SIZE];
 extern int udev_log_priority;
 extern int udev_run;
 extern void udev_config_init(void);
index 3d18e59..3f226b9 100644 (file)
@@ -31,7 +31,7 @@
 /* global variables */
 char udev_root[PATH_SIZE];
 char udev_config_filename[PATH_SIZE];
-char udev_rules_filename[PATH_SIZE];
+char udev_rules_dir[PATH_SIZE];
 int udev_log_priority;
 int udev_run;
 
@@ -145,8 +145,8 @@ static int parse_config_file(void)
                }
 
                if (strcasecmp(variable, "udev_rules") == 0) {
-                       strlcpy(udev_rules_filename, value, sizeof(udev_rules_filename));
-                       remove_trailing_chars(udev_rules_filename, '/');
+                       strlcpy(udev_rules_dir, value, sizeof(udev_rules_dir));
+                       remove_trailing_chars(udev_rules_dir, '/');
                        continue;
                }
 
@@ -166,7 +166,7 @@ void udev_config_init(void)
 
        strcpy(udev_root, UDEV_ROOT);
        strcpy(udev_config_filename, UDEV_CONFIG_FILE);
-       strcpy(udev_rules_filename, UDEV_RULES_FILE);
+       strcpy(udev_rules_dir, UDEV_RULES_DIR);
        udev_log_priority = LOG_ERR;
        udev_run = 1;
 
@@ -195,6 +195,6 @@ void udev_config_init(void)
 
        dbg("UDEV_CONFIG_FILE='%s'", udev_config_filename);
        dbg("udev_root='%s'", udev_root);
-       dbg("udev_rules='%s'", udev_rules_filename);
+       dbg("udev_rules='%s'", udev_rules_dir);
        dbg("udev_log=%d", udev_log_priority);
 }
index 4a9cd58..5615351 100644 (file)
@@ -24,7 +24,7 @@
 #include "list.h"
 
 #define PAIRS_MAX              5
-#define RULEFILE_SUFFIX                ".rules"
+#define RULESFILE_SUFFIX       ".rules"
 
 enum key_operation {
        KEY_OP_UNSET,
index 535b595..3f7e43f 100644 (file)
@@ -627,7 +627,7 @@ static int parse_file(struct udev_rules *rules, const char *filename)
                err("can't open '%s' as rules file: %s", filename, strerror(errno));
                return -1;
        }
-       dbg("reading '%s' as rules file", filename);
+       info("reading '%s' as rules file", filename);
 
        /* loop through the whole file */
        cur = 0;
@@ -683,18 +683,18 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
        rules->resolve_names = resolve_names;
 
        /* parse rules file or all matching files in directory */
-       if (stat(udev_rules_filename, &stats) != 0)
+       if (stat(udev_rules_dir, &stats) != 0)
                return -1;
 
        if ((stats.st_mode & S_IFMT) != S_IFDIR) {
-               dbg("parse single rules file '%s'", udev_rules_filename);
-               retval = parse_file(rules, udev_rules_filename);
+               dbg("parse single rules file '%s'", udev_rules_dir);
+               retval = parse_file(rules, udev_rules_dir);
        } else {
                struct name_entry *name_loop, *name_tmp;
                LIST_HEAD(name_list);
 
-               dbg("parse rules directory '%s'", udev_rules_filename);
-               retval = add_matching_files(&name_list, udev_rules_filename, RULEFILE_SUFFIX);
+               dbg("parse rules directory '%s'", udev_rules_dir);
+               retval = add_matching_files(&name_list, udev_rules_dir, RULESFILE_SUFFIX);
 
                list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) {
                        if (stat(name_loop->name, &stats) == 0) {
index b6e5275..e892012 100644 (file)
@@ -126,7 +126,6 @@ int add_matching_files(struct list_head *name_list, const char *dirname, const c
 {
        struct dirent *ent;
        DIR *dir;
-       char *ext;
        char filename[PATH_SIZE];
 
        dbg("open directory '%s'", dirname);
@@ -145,14 +144,16 @@ int add_matching_files(struct list_head *name_list, const char *dirname, const c
                        continue;
 
                /* look for file matching with specified suffix */
-               ext = strrchr(ent->d_name, '.');
-               if (ext == NULL)
-                       continue;
-
-               if (strcmp(ext, suffix) != 0)
-                       continue;
-
-               dbg("put file '%s/%s' in list", dirname, ent->d_name);
+               if (suffix != NULL) {
+                       const char *ext;
+
+                       ext = strrchr(ent->d_name, '.');
+                       if (ext == NULL)
+                               continue;
+                       if (strcmp(ext, suffix) != 0)
+                               continue;
+               }
+               dbg("put file '%s/%s' into list", dirname, ent->d_name);
 
                snprintf(filename, sizeof(filename), "%s/%s", dirname, ent->d_name);
                filename[sizeof(filename)-1] = '\0';
diff --git a/udevd.c b/udevd.c
index 3adedac..79465a1 100644 (file)
--- a/udevd.c
+++ b/udevd.c
@@ -1104,7 +1104,7 @@ int main(int argc, char *argv[], char *envp[])
        /* watch rules directory */
        inotify_fd = inotify_init();
        if (inotify_fd >= 0)
-               inotify_add_watch(inotify_fd, udev_rules_filename, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
+               inotify_add_watch(inotify_fd, udev_rules_dir, IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
        else if (errno == ENOSYS)
                err("the kernel does not support inotify, udevd can't monitor configuration file changes");
        else