summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-04-20 17:58:58 +0200
committerKay Sievers <kay.sievers@vrfy.org>2011-04-20 17:58:58 +0200
commita178e7fe90c5f9a4f9f196575102ab6812bb5973 (patch)
treee6caabc3a9eed4fb683ce905191b4e7e3ba6fc1c
parentdff107dc1a12538d351798d43191ae5d07d3c6d6 (diff)
udevd: rules files - accept empty or /dev/null links
-rw-r--r--TODO2
-rw-r--r--udev/udev-rules.c19
2 files changed, 14 insertions, 7 deletions
diff --git a/TODO b/TODO
index 0ecc9c1506..54b0fe5286 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
- - empty rules files and link to /dev/null are ok
-
- kill tabs?
- remove deprecated trigger --type=failed logic
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);
}