aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-04-10 15:15:21 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-04-10 15:15:21 +0200
commitdf506d8aeef9ec113c455f3a5f3d471b0a8529e6 (patch)
treeb8611ec7cd014d5125978973ab7aa2e5eb13de4c
parent0bf1d7e7427fb7165dfb547d4de1c84da6f963ea (diff)
Refactor setting of directories
When not specified, the default directories are now ".". The workdir is relative to the current directory and other directories are relative the the workdir. Change-Id: I52c013e3a3c93b3f984903562cf0c56d990900e6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-config.c6
-rw-r--r--src/main.c11
2 files changed, 8 insertions, 9 deletions
diff --git a/src/afb-config.c b/src/afb-config.c
index 347198da..1b4a3693 100644
--- a/src/afb-config.c
+++ b/src/afb-config.c
@@ -559,13 +559,13 @@ static void config_set_default(struct afb_config *config)
/* set directories */
if (config->workdir == NULL)
- config->workdir = get_current_dir_name();
+ config->workdir = ".";
if (config->rootdir == NULL)
- config->rootdir = config->workdir;
+ config->rootdir = ".";
if (config->uploaddir == NULL)
- config->uploaddir = config->workdir;
+ config->uploaddir = ".";
// if no Angular/HTML5 rootbase let's try '/' as default
if (config->rootbase == NULL)
diff --git a/src/main.c b/src/main.c
index 6db1e2a8..0bfa5292 100644
--- a/src/main.c
+++ b/src/main.c
@@ -444,11 +444,16 @@ static void start()
goto error;
}
+ /* set the directories */
mkdir(config->workdir, S_IRWXU | S_IRGRP | S_IXGRP);
if (chdir(config->workdir) < 0) {
ERROR("Can't enter working dir %s", config->workdir);
goto error;
}
+ if (afb_common_rootdir_set(config->rootdir) < 0) {
+ ERROR("failed to set common root directory");
+ goto error;
+ }
/* install hooks */
if (config->tracereq)
@@ -472,12 +477,6 @@ static void start()
goto error;
}
- // set the root dir
- if (afb_common_rootdir_set(config->rootdir) < 0) {
- ERROR("failed to set common root directory");
- goto error;
- }
-
DEBUG("Init config done");
/* start the services */