diff options
author | Kay Sievers <kay@vrfy.org> | 2012-10-26 03:43:56 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2012-10-26 03:45:25 +0200 |
commit | 4af113f9971217991cce51b45f15bdce22ee45e2 (patch) | |
tree | 1c19ee53d43cc9a33f1865e3ad900962c81848e1 /src/udev | |
parent | a4bcff5ba36115495994e9f9ba66074471de76ab (diff) |
udev: builtin - do not fail builtin initialization if one of them returns an error
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udev-builtin-hwdb.c | 11 | ||||
-rw-r--r-- | src/udev/udev-builtin.c | 24 | ||||
-rw-r--r-- | src/udev/udev.h | 2 |
3 files changed, 16 insertions, 21 deletions
diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c index c1a6f5c791..14e9edab82 100644 --- a/src/udev/udev-builtin-hwdb.c +++ b/src/udev/udev-builtin-hwdb.c @@ -311,11 +311,14 @@ static int builtin_hwdb_init(struct udev *udev) return 0; trie.f = fopen(SYSCONFDIR "/udev/hwdb.bin", "re"); - if (!trie.f) + if (!trie.f) { + if (errno != EEXIST) + log_error("Error reading " SYSCONFDIR "/udev/hwdb.bin: %m"); return -errno; + } if (fstat(fileno(trie.f), &st) < 0 || (size_t)st.st_size < offsetof(struct trie_header_f, strings_len) + 8) { - log_error("Error reading '%s'.", SYSCONFDIR "/udev/hwdb.bin: %m"); + log_error("Error reading " SYSCONFDIR "/udev/hwdb.bin: %m"); fclose(trie.f); zero(trie); return -EINVAL; @@ -323,7 +326,7 @@ static int builtin_hwdb_init(struct udev *udev) trie.map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fileno(trie.f), 0); if (trie.map == MAP_FAILED) { - log_error("Error mapping '%s'.", SYSCONFDIR "/udev/hwdb.bin: %m"); + log_error("Error mapping " SYSCONFDIR "/udev/hwdb.bin: %m"); fclose(trie.f); return -EINVAL; } @@ -331,7 +334,7 @@ static int builtin_hwdb_init(struct udev *udev) trie.map_size = st.st_size; if (memcmp(trie.map, sig, sizeof(trie.head->signature)) != 0 || (size_t)st.st_size != le64toh(trie.head->file_size)) { - log_error("Unable to recognize the format of '%s'.", SYSCONFDIR "/udev/hwdb.bin"); + log_error("Unable to recognize the format of " SYSCONFDIR "/udev/hwdb.bin."); log_error("Please try 'udevadm hwdb --update' to re-create it."); munmap((void *)trie.map, st.st_size); fclose(trie.f); diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c index 26ee16c669..2ea7f4e202 100644 --- a/src/udev/udev-builtin.c +++ b/src/udev/udev-builtin.c @@ -41,24 +41,18 @@ static const struct udev_builtin *builtins[] = { #endif }; -int udev_builtin_init(struct udev *udev) +void udev_builtin_init(struct udev *udev) { unsigned int i; - int err = 0; if (initialized) - return 0; + return; - for (i = 0; i < ELEMENTSOF(builtins); i++) { - if (builtins[i]->init) { - err = builtins[i]->init(udev); - if (err < 0) - break; - } - } + for (i = 0; i < ELEMENTSOF(builtins); i++) + if (builtins[i]->init) + builtins[i]->init(udev); initialized = true; - return err; } void udev_builtin_exit(struct udev *udev) @@ -78,13 +72,11 @@ void udev_builtin_exit(struct udev *udev) bool udev_builtin_validate(struct udev *udev) { unsigned int i; - bool change = false; for (i = 0; i < ELEMENTSOF(builtins); i++) - if (builtins[i]->validate) - if (builtins[i]->validate(udev)) - change = true; - return change; + if (builtins[i]->validate && builtins[i]->validate(udev)) + return true; + return false; } void udev_builtin_list(struct udev *udev) diff --git a/src/udev/udev.h b/src/udev/udev.h index a2c84f6aeb..f85c7216d2 100644 --- a/src/udev/udev.h +++ b/src/udev/udev.h @@ -165,7 +165,7 @@ extern const struct udev_builtin udev_builtin_kmod; extern const struct udev_builtin udev_builtin_path_id; extern const struct udev_builtin udev_builtin_usb_id; extern const struct udev_builtin udev_builtin_uaccess; -int udev_builtin_init(struct udev *udev); +void udev_builtin_init(struct udev *udev); void udev_builtin_exit(struct udev *udev); enum udev_builtin_cmd udev_builtin_lookup(const char *command); const char *udev_builtin_name(enum udev_builtin_cmd cmd); |