diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-01-18 15:51:13 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-02-15 17:16:54 +0100 |
commit | 76e15a9cab0e0b0b8a166c14f60b170ff5cb58fd (patch) | |
tree | 49bbc8362c48f1bd2ac72de08a4479bf5f78af92 /src/tmpfiles | |
parent | 791cd1599311d2cfffec9cc7d2915b36cbd3047d (diff) | |
download | systemd-76e15a9cab0e0b0b8a166c14f60b170ff5cb58fd.tar.gz systemd-76e15a9cab0e0b0b8a166c14f60b170ff5cb58fd.tar.bz2 systemd-76e15a9cab0e0b0b8a166c14f60b170ff5cb58fd.zip |
tmpfiles: clean up restoring of access times after aging a bit
Let's minimize file scope, use compund literals and only use LOG_WARN
for errors we ignore.
Diffstat (limited to 'src/tmpfiles')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index b66765b407..50a0243d98 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -525,7 +525,6 @@ static int dir_cleanup( bool keep_this_level) { struct dirent *dent; - struct timespec times[2]; bool deleted = false; int r = 0; @@ -722,21 +721,22 @@ static int dir_cleanup( finish: if (deleted) { - usec_t age1, age2; char a[FORMAT_TIMESTAMP_MAX], b[FORMAT_TIMESTAMP_MAX]; - - /* Restore original directory timestamps */ - times[0] = ds->st_atim; - times[1] = ds->st_mtim; + usec_t age1, age2; age1 = timespec_load(&ds->st_atim); age2 = timespec_load(&ds->st_mtim); + log_debug("Restoring access and modification time on \"%s\": %s, %s", p, format_timestamp_us(a, sizeof(a), age1), format_timestamp_us(b, sizeof(b), age2)); - if (futimens(dirfd(d), times) < 0) - log_error_errno(errno, "utimensat(%s): %m", p); + + /* Restore original directory timestamps */ + if (futimens(dirfd(d), (struct timespec[]) { + ds->st_atim, + ds->st_mtim }) < 0) + log_warning_errno(errno, "Failed to revert timestamps of '%s', ignoring: %m", p); } return r; |