From: Jan Alexander Steffens (heftig) Date: Fri, 24 Mar 2023 00:48:05 +0000 (+0100) Subject: debuginfod: When retrieving files from cache, update atime manually X-Git-Tag: elfutils-0.190~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a568e216765d41dacf8718cf2fabeec50bab16a9;p=thirdparty%2Felfutils.git 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) --- diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index c8c562325..f13c28d5c 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,8 @@ +2023-03-30 Jan Alexander Steffens (heftig) + + * debuginfod-client.c (update_atime): New function. + (extract_section, debuginfod_query_server): Call it. + 2023-03-30 Jan Alexander Steffens (heftig) * debuginfod-client.c (debuginfod_query_server): Don't modify diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index 7d0b153e1..5bb795241 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; }