]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: When retrieving files from cache, update atime manually
authorJan Alexander Steffens (heftig) <heftig@archlinux.org>
Fri, 24 Mar 2023 00:48:05 +0000 (01:48 +0100)
committerFrank Ch. Eigler <fche@redhat.com>
Thu, 30 Mar 2023 18:56:26 +0000 (14:56 -0400)
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>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c

index c8c562325745595526c809fbf3f48eab3b242caf..f13c28d5c6f723c87ead5b54d8476ef98df4e91b 100644 (file)
@@ -1,3 +1,8 @@
+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
index 7d0b153e1f91cbb21bfd33bdcdc41e88acdfd9de..5bb7952416e6c71ba61b9d0ba3c12e24678e4ff6 100644 (file)
@@ -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;
         }