aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-11-29 13:54:36 +0100
committerLudovic Courtès <ludo@gnu.org>2019-11-29 15:54:20 +0100
commitb6b014bf42f68fcb71d37204328babb81e0e0855 (patch)
tree05755932bb72831e49e711d8ca097c212a1bc948
parent68ac34e1209c8ba631aea119a2a547f267a88576 (diff)
downloadguix-b6b014bf42f68fcb71d37204328babb81e0e0855.tar
guix-b6b014bf42f68fcb71d37204328babb81e0e0855.tar.gz
daemon: 'pathExists' uses 'statx' when available.
* nix/libutil/util.cc (pathExists) [HAVE_STATX]: New code.
-rw-r--r--nix/libutil/util.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc
index 8093b4c8b4..faba3789df 100644
--- a/nix/libutil/util.cc
+++ b/nix/libutil/util.cc
@@ -177,8 +177,13 @@ struct stat lstat(const Path & path)
bool pathExists(const Path & path)
{
int res;
+#ifdef HAVE_STATX
+ struct statx st;
+ res = statx(AT_FDCWD, path.c_str(), AT_SYMLINK_NOFOLLOW, 0, &st);
+#else
struct stat st;
res = lstat(path.c_str(), &st);
+#endif
if (!res) return true;
if (errno != ENOENT && errno != ENOTDIR)
throw SysError(format("getting status of %1%") % path);