]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: explicitly update mtime of EFI variables when changing them
authorLennart Poettering <lennart@poettering.net>
Wed, 27 May 2020 15:22:46 +0000 (17:22 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 29 May 2020 13:41:31 +0000 (15:41 +0200)
src/basic/efivars.c

index 496b5d4d44f280bec020e6355192e1e11e52758f..16982e4784c5b4bc90ac71085237bf4c89469ed9 100644 (file)
@@ -231,6 +231,14 @@ int efi_set_variable(
         if (r < 0)
                 goto finish;
 
+        /* For some reason efivarfs doesn't update mtime automatically. Let's do it manually then. This is
+         * useful for processes that cache EFI variables to detect when changes occurred. */
+        if (futimens(fd, (struct timespec[2]) {
+                                { .tv_nsec = UTIME_NOW },
+                                { .tv_nsec = UTIME_NOW }
+                        }) < 0)
+                log_debug_errno(errno, "Failed to update mtime/atime on %s, ignoring: %m", p);
+
         r = 0;
 
 finish: