$(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
/* 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);
/* 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;
}
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;
}
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;
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);
}
#include "list.h"
#define PAIRS_MAX 5
-#define RULEFILE_SUFFIX ".rules"
+#define RULESFILE_SUFFIX ".rules"
enum key_operation {
KEY_OP_UNSET,
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;
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) {
{
struct dirent *ent;
DIR *dir;
- char *ext;
char filename[PATH_SIZE];
dbg("open directory '%s'", dirname);
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';
/* 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