common: New function ctdb_mkdir_p_or_die()
authorMartin Schwenke <martin@meltin.net>
Mon, 21 Oct 2013 08:29:39 +0000 (19:29 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 25 Oct 2013 01:06:06 +0000 (12:06 +1100)
Signed-off-by: Martin Schwenke <martin@meltin.net>
common/ctdb_util.c
include/ctdb_private.h

index d4f85416c0cf8f96761bf781fd3ea1e32657a759..7a70fea9cd71c1c51eeedff6d3c68a294d1daff4 100644 (file)
@@ -811,3 +811,17 @@ void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate)
                            runstate_to_string(runstate), runstate));
        ctdb->runstate = runstate;
 }
+
+void ctdb_mkdir_p_or_die(struct ctdb_context *ctdb, const char *dir, int mode)
+{
+       int ret;
+
+       ret = mkdir_p(dir, mode);
+       if (ret != 0) {
+               DEBUG(DEBUG_ALERT,
+                     ("ctdb exiting with error: "
+                      "failed to create directory \"%s\" (%s)\n",
+                      dir, strerror(ret)));
+               exit(1);
+       }
+}
index bc0b8d52d83356e48b4c1eac030bf7559637bf4f..e961b9310a1cc45a9c485d7779f75edd6c34f9da 100644 (file)
@@ -1589,5 +1589,6 @@ struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
                                     void *private_data);
 
 int mkdir_p(const char *dir, int mode);
+void ctdb_mkdir_p_or_die(struct ctdb_context *ctdb, const char *dir, int mode);
 
 #endif