diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-03-04 23:16:17 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-03-04 23:16:17 +0100 |
commit | ebb7cf9e21060105d9950dd5142c0eb918083666 (patch) | |
tree | 36c1607b80d92e27fb9d09029d1d3b57a1fd5065 /nix/libstore/gc.cc | |
parent | 0b870f7915f5da43758753fd088a22033936dc50 (diff) | |
parent | c2d7e800e6788277bc56f31d5836f9d507dc1506 (diff) | |
download | patches-ebb7cf9e21060105d9950dd5142c0eb918083666.tar patches-ebb7cf9e21060105d9950dd5142c0eb918083666.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'nix/libstore/gc.cc')
-rw-r--r-- | nix/libstore/gc.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/nix/libstore/gc.cc b/nix/libstore/gc.cc index 77d7fa2dc7..8bc4e01eb0 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; |