diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2019-11-29 13:54:36 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2019-11-29 15:54:20 +0100 |
| commit | b6b014bf42f68fcb71d37204328babb81e0e0855 (patch) | |
| tree | 05755932bb72831e49e711d8ca097c212a1bc948 /nix/libutil | |
| parent | 68ac34e1209c8ba631aea119a2a547f267a88576 (diff) | |
daemon: 'pathExists' uses 'statx' when available.
* nix/libutil/util.cc (pathExists) [HAVE_STATX]: New code.
Diffstat (limited to 'nix/libutil')
| -rw-r--r-- | nix/libutil/util.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/nix/libutil/util.cc b/nix/libutil/util.cc index 8093b4c8b45..faba3789df3 100644 --- a/nix/libutil/util.cc +++ b/nix/libutil/util.cc | |||
| @@ -177,8 +177,13 @@ struct stat lstat(const Path & path) | |||
| 177 | bool pathExists(const Path & path) | 177 | bool pathExists(const Path & path) |
| 178 | { | 178 | { |
| 179 | int res; | 179 | int res; |
| 180 | #ifdef HAVE_STATX | ||
| 181 | struct statx st; | ||
| 182 | res = statx(AT_FDCWD, path.c_str(), AT_SYMLINK_NOFOLLOW, 0, &st); | ||
| 183 | #else | ||
| 180 | struct stat st; | 184 | struct stat st; |
| 181 | res = lstat(path.c_str(), &st); | 185 | res = lstat(path.c_str(), &st); |
| 186 | #endif | ||
| 182 | if (!res) return true; | 187 | if (!res) return true; |
| 183 | if (errno != ENOENT && errno != ENOTDIR) | 188 | if (errno != ENOENT && errno != ENOTDIR) |
| 184 | throw SysError(format("getting status of %1%") % path); | 189 | throw SysError(format("getting status of %1%") % path); |
