summaryrefslogtreecommitdiffstats
path: root/src/vlib/unix/util.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-07-20 19:17:06 +0200
committerDave Wallace <dwallacelf@gmail.com>2017-08-24 19:49:09 +0000
commit57d963f88b2c99e698e2b29f72e190f47f41b1ad (patch)
tree0a26d5fd1e09b4b997db5950fe9bf70835ab9798 /src/vlib/unix/util.c
parentd48e9763bfc39106eca954a28223b72261bf1aeb (diff)
Make VPP runtime directory configurable
New startup config command: unix { runtime-dir /run/vpp } Also, adds recursive mkdir funtion for use in deifferent places like cli-config socket path and dpdk hugepage directory path. Change-Id: I1446ceab9c220c25804e73a743a3ebb383450124 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vlib/unix/util.c')
-rw-r--r--src/vlib/unix/util.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/vlib/unix/util.c b/src/vlib/unix/util.c
index 51b4a4ed9b1..93aeb99c5d9 100644
--- a/src/vlib/unix/util.c
+++ b/src/vlib/unix/util.c
@@ -223,16 +223,38 @@ done:
}
clib_error_t *
-unix_make_vpp_run_dir (void)
+vlib_unix_recursive_mkdir (char *path)
{
- int rv;
+ clib_error_t *error = 0;
+ char *c = 0;
+ int i = 0;
- rv = mkdir (VPP_RUN_DIR, 0755);
- if (rv && errno != EEXIST)
- return clib_error_return (0, "mkdir '%s' failed errno %d",
- VPP_RUN_DIR, errno);
+ while (path[i] != 0)
+ {
+ if (c && path[i] == '/')
+ {
+ vec_add1 (c, 0);
+ if ((mkdir (c, 0755)) && (errno != EEXIST))
+ {
+ error = clib_error_return_unix (0, "mkdir '%s'", c);
+ goto done;
+ }
+ _vec_len (c)--;
+ }
+ vec_add1 (c, path[i]);
+ i++;
+ }
- return 0;
+ if ((mkdir (path, 0755)) && (errno != EEXIST))
+ {
+ error = clib_error_return_unix (0, "mkdir '%s'", path);
+ goto done;
+ }
+
+done:
+ vec_free (c);
+
+ return error;
}
/*