summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-11-26 23:35:24 +0100
committerLudovic Courtès <ludo@gnu.org>2019-11-27 00:03:03 +0100
commit7738a72186583afb3bb2e0a866c8aba130372400 (patch)
treeadfc37a8db5beb8b49c5d2b4f2e9c90a7742b007 /nix
parent434138e2f26b28bb5cc83e62327aae8ed0902475 (diff)
downloadguix-7738a72186583afb3bb2e0a866c8aba130372400.tar.gz
daemon: GC remove-unused-links phase uses 'statx' when available.
* config-daemon.ac: Check for 'statx'.
* nix/libstore/gc.cc (LocalStore::removeUnusedLinks) [HAVE_STATX]: Use
'statx' instead of 'lstat'.
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/gc.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc
index 7976ff7d76..29b75aa875 100644
--- a/nix/libstore/gc.cc
+++ b/nix/libstore/gc.cc
@@ -570,8 +570,17 @@ void LocalStore::removeUnusedLinks(const GCState & state)
         if (name == "." || name == "..") continue;
         Path path = linksDir + "/" + name;
 
+#ifdef HAVE_STATX
+# define st_size stx_size
+# define st_nlink stx_nlink
+	struct statx st;
+	if (statx(AT_FDCWD, path.c_str(),
+		  AT_SYMLINK_NOFOLLOW | AT_STATX_DONT_SYNC,
+		  STATX_SIZE | STATX_NLINK, &st) == -1)
+#else
         struct stat st;
         if (lstat(path.c_str(), &st) == -1)
+#endif
             throw SysError(format("statting `%1%'") % path);
 
         if (st.st_nlink != 1) {
@@ -586,6 +595,8 @@ void LocalStore::removeUnusedLinks(const GCState & state)
             throw SysError(format("deleting `%1%'") % path);
 
         state.results.bytesFreed += st.st_size;
+#undef st_size
+#undef st_nlink
     }
 
     struct stat st;