summaryrefslogtreecommitdiff
path: root/src/gpt-auto-generator
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-25 10:06:23 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-25 12:22:06 +0200
commite137880b2a58bd899c7d0e15dc24aa20fe02ab31 (patch)
tree861675b831cced337f6e0473d30e617eb8e783b1 /src/gpt-auto-generator
parent2aa2860bc3ec70e39217795b9ceac759b4bf1735 (diff)
downloadsystemd-e137880b2a58bd899c7d0e15dc24aa20fe02ab31.tar.gz
gpt-auto-generator: emit warnings and fail if we fail to query mount points
Right now gpt-auto-generator will iterate through all mount entries, and silently ignore failure to check if the mount point target is empty. This can hide real errors (in particular from MAC), so instead let's warn and return failure at the end if this happens. We will still iterate over other candidates, so there should be no change in behaviour. Logging is moved into path_is_busy() to avoid the duplication of the same logging code in the two callers.
Diffstat (limited to 'src/gpt-auto-generator')
-rw-r--r--src/gpt-auto-generator/gpt-auto-generator.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c
index 5b03f45372..66f916b4de 100644
--- a/src/gpt-auto-generator/gpt-auto-generator.c
+++ b/src/gpt-auto-generator/gpt-auto-generator.c
@@ -230,7 +230,7 @@ static int add_mount(
return 0;
}
-static bool path_is_busy(const char *where) {
+static int path_is_busy(const char *where) {
int r;
/* already a mountpoint; generators run during reload */
@@ -243,13 +243,17 @@ static bool path_is_busy(const char *where) {
return false;
if (r < 0)
- return true;
+ return log_warning_errno(r, "Cannot check if \"%s\" is a mount point: %m", where);
/* not a mountpoint but it contains files */
- if (dir_is_empty(where) <= 0)
- return true;
+ r = dir_is_empty(where);
+ if (r < 0)
+ return log_warning_errno(r, "Cannot check if \"%s\" is empty: %m", where);
+ if (r > 0)
+ return false;
- return false;
+ log_debug("\"%s\" already populated, ignoring.", where);
+ return true;
}
static int add_partition_mount(
@@ -258,12 +262,12 @@ static int add_partition_mount(
const char *where,
const char *description) {
+ int r;
assert(p);
- if (path_is_busy(where)) {
- log_debug("%s already populated, ignoring.", where);
- return 0;
- }
+ r = path_is_busy(where);
+ if (r != 0)
+ return r < 0 ? r : 0;
return add_mount(
id,
@@ -407,10 +411,9 @@ static int add_esp(DissectedPartition *p) {
return 0;
}
- if (path_is_busy(esp)) {
- log_debug("%s already populated, ignoring.", esp);
- return 0;
- }
+ r = path_is_busy(esp);
+ if (r != 0)
+ return r < 0 ? r : 0;
if (is_efi_boot()) {
sd_id128_t loader_uuid;