From 4d513a5063879aa41c5ce27d245a7c56ecaa6e79 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 23 Jan 2013 13:38:53 -0500 Subject: [PATCH] relayd: Create output directory in main() If specified with -o, --output, the directory is created in the main() so if an error occurs the execution is stopped. Signed-off-by: David Goulet --- src/bin/lttng-relayd/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index cd17dcd67..4f9d74274 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2107,6 +2107,15 @@ int main(int argc, char **argv) goto exit; } + /* Try to create directory if -o, --output is specified. */ + if (opt_output_path) { + ret = utils_mkdir_recursive(opt_output_path, S_IRWXU | S_IRWXG); + if (ret < 0) { + ERR("Unable to create %s", opt_output_path); + goto exit; + } + } + /* Daemonize */ if (opt_daemon) { ret = daemon(0, 0); -- 2.34.1