From eb33876c262bec79a127b82a3a853ad00665d894 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 10 Nov 2015 12:42:38 +0100 Subject: initdb: make safe_create_dir public Soon we will want to create initdb functions for ref backends, and code from initdb that calls this function needs to move into the files backend. So this function needs to be public. Signed-off-by: David Turner Signed-off-by: Junio C Hamano Signed-off-by: Michael Haggerty Signed-off-by: Jeff King --- path.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'path.c') diff --git a/path.c b/path.c index c740c4ff94..9d1ab1f69e 100644 --- a/path.c +++ b/path.c @@ -740,6 +740,18 @@ int adjust_shared_perm(const char *path) return 0; } +void safe_create_dir(const char *dir, int share) +{ + if (mkdir(dir, 0777) < 0) { + if (errno != EEXIST) { + perror(dir); + exit(1); + } + } + else if (share && adjust_shared_perm(dir)) + die(_("Could not make %s writable by group"), dir); +} + static int have_same_root(const char *path1, const char *path2) { int is_abs1, is_abs2; -- cgit v1.2.3