diff options
author | Jan Alexander Steffens (heftig) <heftig@archlinux.org> | 2023-03-24 01:48:05 +0100 |
---|---|---|
committer | Frank Ch. Eigler <fche@redhat.com> | 2023-03-30 14:56:26 -0400 |
commit | a568e216765d41dacf8718cf2fabeec50bab16a9 (patch) | |
tree | 4d445ddb131508f10bc9c1db87a0a5355cd24398 /debuginfod | |
parent | 1b4cf71db1f72c53ff34c0e5c4a9da67dc24fdd6 (diff) | |
download | elfutils-a568e216765d41dacf8718cf2fabeec50bab16a9.tar.gz |
debuginfod: When retrieving files from cache, update atime manually
The cache cleaning logic requires atime to be correct (strictatime or
relatime) but some users on Linux only have noatime.
Attempt to update the atime manually so that the cache works properly.
Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Diffstat (limited to 'debuginfod')
-rw-r--r-- | debuginfod/ChangeLog | 5 | ||||
-rw-r--r-- | debuginfod/debuginfod-client.c | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index c8c56232..f13c28d5 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,5 +1,10 @@ 2023-03-30 Jan Alexander Steffens (heftig) <heftig@archlinux.org> + * debuginfod-client.c (update_atime): New function. + (extract_section, debuginfod_query_server): Call it. + +2023-03-30 Jan Alexander Steffens (heftig) <heftig@archlinux.org> + * debuginfod-client.c (debuginfod_query_server): Don't modify atime unintentionally. * debuginfod.cxx (extract_section, handle_buildid_r_match): Ditto. diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 7d0b153e..5bb79524 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -618,6 +618,19 @@ path_escape (const char *src, char *dest) dest[q] = '\0'; } +/* Attempt to update the atime */ +static void +update_atime (int fd) +{ + struct timespec tvs[2]; + + tvs[0].tv_sec = tvs[1].tv_sec = 0; + tvs[0].tv_nsec = UTIME_NOW; + tvs[1].tv_nsec = UTIME_OMIT; + + (void) futimens (fd, tvs); /* best effort */ +} + /* Attempt to read an ELF/DWARF section with name SECTION from FD and write it to a separate file in the debuginfod cache. If successful the absolute path of the separate file containing SECTION will be stored in USR_PATH. @@ -761,6 +774,7 @@ extract_section (int fd, const char *section, char *fd_path, char **usr_path) *usr_path = sec_path; else free (sec_path); + update_atime(fd); rc = sec_fd; goto out2; } @@ -1098,6 +1112,7 @@ debuginfod_query_server (debuginfod_client *c, } } /* Success!!!! */ + update_atime(fd); rc = fd; goto out; } |