mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
rename config "filename" to "dir"
This commit is contained in:
parent
768cd81b7d
commit
9dd0c2573b
2
Makefile
2
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
|
||||
|
2
udev.h
2
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
17
udev_utils.c
17
udev_utils.c
@ -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 (suffix != NULL) {
|
||||
const char *ext;
|
||||
|
||||
if (strcmp(ext, suffix) != 0)
|
||||
continue;
|
||||
|
||||
dbg("put file '%s/%s' in list", dirname, ent->d_name);
|
||||
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';
|
||||
|
2
udevd.c
2
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user