Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
return 0;
}
+
+bool exists_dir_at(int dir_fd, const char *path)
+{
+ struct stat sb;
+ int ret;
+
+ ret = fstatat(dir_fd, path, &sb, 0);
+ if (ret < 0)
+ return false;
+
+ return S_ISDIR(sb.st_mode);
+}
__hidden extern FILE *fdopen_cached(int fd, const char *mode, void **caller_freed_buffer);
__hidden extern FILE *fopen_cached(const char *path, const char *mode, void **caller_freed_buffer);
__hidden extern int timens_offset_write(clockid_t clk_id, int64_t s_offset, int64_t ns_offset);
+__hidden extern bool exists_dir_at(int dir_fd, const char *path);
#endif /* __LXC_FILE_UTILS_H */
bool dir_exists(const char *path)
{
- struct stat sb;
- int ret;
-
- ret = stat(path, &sb);
- if (ret < 0)
- /* Could be something other than eexist, just say "no". */
- return false;
-
- return S_ISDIR(sb.st_mode);
+ return exists_dir_at(-1, path);
}
/* Note we don't use SHA-1 here as we don't want to depend on HAVE_GNUTLS.