diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2011-04-20 17:58:58 +0200 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2011-04-20 17:58:58 +0200 |
commit | a178e7fe90c5f9a4f9f196575102ab6812bb5973 (patch) | |
tree | e6caabc3a9eed4fb683ce905191b4e7e3ba6fc1c /udev | |
parent | dff107dc1a12538d351798d43191ae5d07d3c6d6 (diff) |
udevd: rules files - accept empty or /dev/null links
Diffstat (limited to 'udev')
-rw-r--r-- | udev/udev-rules.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/udev/udev-rules.c b/udev/udev-rules.c index a786bfb14f..d38c9ff4ff 100644 --- a/udev/udev-rules.c +++ b/udev/udev-rules.c @@ -1760,7 +1760,6 @@ static int add_matching_files(struct udev *udev, struct udev_list_node *file_lis struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) { struct udev_rules *rules; - struct stat statbuf; struct udev_list_node file_list; struct udev_list_entry *file_loop, *file_tmp; struct token end_token; @@ -1877,11 +1876,21 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) udev_list_entry_foreach_safe(file_loop, file_tmp, udev_list_get_entry(&file_list)) { const char *filename = udev_list_entry_get_name(file_loop); unsigned int filename_off = udev_list_entry_get_flags(file_loop); + struct stat st; - if (stat(filename, &statbuf) == 0 && statbuf.st_size > 0) - parse_file(rules, filename, filename_off); - else - err(udev, "can not read '%s'\n", filename); + if (stat(filename, &st) != 0) { + err(udev, "can not find '%s': %m\n", filename); + continue; + } + if (S_ISREG(st.st_mode) && st.st_size <= 0) { + info(udev, "ignore empty '%s'\n", filename); + continue; + } + if (S_ISCHR(st.st_mode)) { + info(udev, "ignore masked '%s'\n", filename); + continue; + } + parse_file(rules, filename, filename_off); udev_list_entry_delete(file_loop); } |