summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-01-14 18:46:33 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2021-04-12 00:12:17 +0200
commit1173d9ff96dcb24245db30fd25e32e0a7e74c6cc (patch)
tree745d52ad1ba6d38f5ee9a1d06cee88076ad36fd2
parentebd4297fc8317a426a6c0faea1cbba2e523270d4 (diff)
Revert "config: remove local mkdir_p implementation"openwrt-19.07
This reverts commit 2cf6232fd170a24b801d71d497947d7aabd12015.
-rw-r--r--src/config.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 78b5855..f8075ba 100644
--- a/src/config.c
+++ b/src/config.c
@@ -190,6 +190,31 @@ static const struct { const char *name; uint8_t flag; } ra_flags[] = {
{ .name = NULL, },
};
+static int mkdir_p(char *dir, mode_t mask)
+{
+ char *l = strrchr(dir, '/');
+ int ret;
+
+ if (!l)
+ return 0;
+
+ *l = '\0';
+
+ if (mkdir_p(dir, mask))
+ return -1;
+
+ *l = '/';
+
+ ret = mkdir(dir, mask);
+ if (ret && errno == EEXIST)
+ return 0;
+
+ if (ret)
+ syslog(LOG_ERR, "mkdir(%s, %d) failed: %m\n", dir, mask);
+
+ return ret;
+}
+
static void set_interface_defaults(struct interface *iface)
{
iface->ignore = true;