condition: add debug log messages on unexpected errors
This commit is contained in:
parent
841c0987f7
commit
df1f5dc1d9
|
@ -546,29 +546,40 @@ static int condition_test_capability(Condition *c, char **env) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int condition_test_needs_update(Condition *c, char **env) {
|
static int condition_test_needs_update(Condition *c, char **env) {
|
||||||
const char *p;
|
|
||||||
struct stat usr, other;
|
struct stat usr, other;
|
||||||
|
const char *p;
|
||||||
|
int r;
|
||||||
|
|
||||||
assert(c);
|
assert(c);
|
||||||
assert(c->parameter);
|
assert(c->parameter);
|
||||||
assert(c->type == CONDITION_NEEDS_UPDATE);
|
assert(c->type == CONDITION_NEEDS_UPDATE);
|
||||||
|
|
||||||
if (!path_is_absolute(c->parameter))
|
if (!path_is_absolute(c->parameter)) {
|
||||||
|
log_debug("Specified condition parameter '%s' is not absolute, assuming an update is needed.", c->parameter);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the file system is read-only we shouldn't suggest an update */
|
/* If the file system is read-only we shouldn't suggest an update */
|
||||||
if (path_is_read_only_fs(c->parameter) > 0)
|
r = path_is_read_only_fs(c->parameter);
|
||||||
|
if (r < 0)
|
||||||
|
log_debug_errno(r, "Failed to determine if '%s' is read-only, ignoring: %m", c->parameter);
|
||||||
|
if (r > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Any other failure means we should allow the condition to be true, so that we rather invoke too
|
/* Any other failure means we should allow the condition to be true, so that we rather invoke too
|
||||||
* many update tools than too few. */
|
* many update tools than too few. */
|
||||||
|
|
||||||
p = strjoina(c->parameter, "/.updated");
|
p = strjoina(c->parameter, "/.updated");
|
||||||
if (lstat(p, &other) < 0)
|
if (lstat(p, &other) < 0) {
|
||||||
|
if (errno != ENOENT)
|
||||||
|
log_debug_errno(errno, "Failed to stat() '%s', assuming an update is needed: %m", p);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (lstat("/usr/", &usr) < 0)
|
if (lstat("/usr/", &usr) < 0) {
|
||||||
|
log_debug_errno(errno, "Failed to stat() /usr/, assuming an update is needed: %m");
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, compare seconds as they are always accurate...
|
* First, compare seconds as they are always accurate...
|
||||||
|
@ -587,7 +598,6 @@ static int condition_test_needs_update(Condition *c, char **env) {
|
||||||
if (usr.st_mtim.tv_nsec > 0 && other.st_mtim.tv_nsec == 0) {
|
if (usr.st_mtim.tv_nsec > 0 && other.st_mtim.tv_nsec == 0) {
|
||||||
_cleanup_free_ char *timestamp_str = NULL;
|
_cleanup_free_ char *timestamp_str = NULL;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
int r;
|
|
||||||
|
|
||||||
r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", ×tamp_str);
|
r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", ×tamp_str);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
|
Loading…
Reference in a new issue