1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-27 18:04:05 +03:00

manager: only issue overmount warning when the check succeeded

If for any reason the check failed (selinux?), we would still issue
the warning. Check the return status.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2014-11-05 22:39:13 -05:00
parent 06d8d842e9
commit 056edeb910

View File

@ -814,19 +814,26 @@ fail:
}
void warn_if_dir_nonempty(const char *unit, const char* where) {
int r;
assert(unit);
assert(where);
if (dir_is_empty(where) > 0)
r = dir_is_empty(where);
if (r > 0)
return;
log_struct_unit(LOG_NOTICE,
unit,
"MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.",
unit, where,
"WHERE=%s", where,
MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
NULL);
else if (r == 0)
log_struct_unit(LOG_NOTICE,
unit,
"MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.",
unit, where,
"WHERE=%s", where,
MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
NULL);
else
log_warning_unit(unit,
"MESSAGE=Failed to check directory %s: %s",
where, strerror(-r));
}
static int fail_if_symlink(const char *unit, const char* where) {