From 1e90a18a085e324b821a8bd0dc28a27082e43634 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 14 Mar 2018 15:22:12 +0100 Subject: Don't rely on mkdir returning EEXISTS (fixing NFS) For NFS mounts if we call mkdir() on a read-only mount (such as when we've created a read-only bind mount) the kernel will nor return EEXIST even when the directory exists, instead returning EROFS. So, we add (and use) an ensure_dir() helper that stats before calling mkdir. Closes: #258 Approved by: giuseppe --- utils.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils.h') diff --git a/utils.h b/utils.h index c0b98bb..52cf772 100644 --- a/utils.h +++ b/utils.h @@ -101,6 +101,8 @@ int create_file (const char *path, const char *content); int ensure_file (const char *path, mode_t mode); +int ensure_dir (const char *path, + mode_t mode); int get_file_mode (const char *pathname); int mkdir_with_parents (const char *pathname, int mode, -- cgit v1.2.1