guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: daemon: Drop 'AT_STATX_DONT_SYNC' flag upon EINVAL.


From: guix-commits
Subject: 01/02: daemon: Drop 'AT_STATX_DONT_SYNC' flag upon EINVAL.
Date: Wed, 26 Feb 2020 16:06:07 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 513c0a0f4602018a49d8fd2dfa24670a3fa08ac9
Author: Ludovic Courtès <address@hidden>
AuthorDate: Wed Feb 26 21:44:48 2020 +0100

    daemon: Drop 'AT_STATX_DONT_SYNC' flag upon EINVAL.
    
    Fixes <https://bugs.gnu.org/39727>.
    Reported by Paul Garlick <address@hidden>.
    
    * nix/libstore/gc.cc (LocalStore::removeUnusedLinks) [HAVE_STATX]: Add
    'statx_flags' static variables.  Clear 'AT_STATX_DONT_SYNC' flag from
    'statx_flags' when 'statx' returns EINVAL.
---
 nix/libstore/gc.cc | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 77d7fa2..8bc4e01 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -581,15 +581,27 @@ void LocalStore::removeUnusedLinks(const GCState & state)
 #ifdef HAVE_STATX
 # define st_size stx_size
 # define st_nlink stx_nlink
+       static int statx_flags = AT_SYMLINK_NOFOLLOW | AT_STATX_DONT_SYNC;
        struct statx st;
-       if (statx(AT_FDCWD, path.c_str(),
-                 AT_SYMLINK_NOFOLLOW | AT_STATX_DONT_SYNC,
-                 STATX_SIZE | STATX_NLINK, &st) == -1)
+
+       if (statx(AT_FDCWD, path.c_str(), statx_flags,
+                 STATX_SIZE | STATX_NLINK, &st) == -1) {
+           if (errno == EINVAL) {
+               /* Old 3.10 kernels (CentOS 7) don't support
+                  AT_STATX_DONT_SYNC, so try again without it.  */
+               statx_flags &= ~AT_STATX_DONT_SYNC;
+               if (statx(AT_FDCWD, path.c_str(), statx_flags,
+                         STATX_SIZE | STATX_NLINK, &st) == -1)
+                   throw SysError(format("statting `%1%'") % path);
+           } else {
+               throw SysError(format("statting `%1%'") % path);
+           }
+       }
 #else
         struct stat st;
         if (lstat(path.c_str(), &st) == -1)
-#endif
             throw SysError(format("statting `%1%'") % path);
+#endif
 
         if (st.st_nlink != 1) {
             actualSize += st.st_size;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]