|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 6dc2852c643df4aa2580d42fc2d268bea0c5f57b Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Lennart Poettering <lennart@poettering.net>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Wed, 3 Sep 2014 19:00:21 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] base-file-system: always generate error messages locally
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Functions either should generate error messages for everything they do
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
themselves, or for nothing and let the caller do it. But they certainly
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
shouldn't generate errors for some messages but not for others. Since
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
the function in this case is one that generates messages on its own, it
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
really should do that for everything, not just for some things, hence.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/base-filesystem.c | 7 ++++---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index ba8b829ab3..4c65a495d3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/base-filesystem.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/base-filesystem.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -58,16 +58,17 @@ int base_filesystem_create(const char *root) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
fd = open(root, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- if (fd < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (fd < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_error("Failed to open root file system: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
for (i = 0; i < ELEMENTSOF(table); i ++) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
continue;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (table[i].target) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const char *target = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
- const char *s;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ const char *target = NULL, *s;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
/* check if one of the targets exists */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
NULSTR_FOREACH(s, table[i].target) {
|