summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-07-14 15:13:34 +0200
committerLucas De Marchi <lucas.demarchi@intel.com>2013-07-15 12:46:12 -0300
commit232bf4d86303d86aff0e29c619f0543b29479c8c (patch)
tree65a42500f2157e7b192ac1b781248ffb5fc96fcc
parentfa6fc9f0b8a749281b14252155a326a5cb1bc41d (diff)
downloadkmod-232bf4d86303d86aff0e29c619f0543b29479c8c.tar.gz
static-nodes: create parent directories of output file
Allows us to drop call to "mkdir -p" from the systemd service file.
-rw-r--r--tools/static-nodes.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/static-nodes.c b/tools/static-nodes.c
index 351c02b..0195390 100644
--- a/tools/static-nodes.c
+++ b/tools/static-nodes.c
@@ -154,12 +154,11 @@ static void help(void)
static int do_static_nodes(int argc, char *argv[])
{
struct utsname kernel;
- char modules[PATH_MAX];
+ char modules[PATH_MAX], buf[4096];
const char *output = "/dev/stdout";
FILE *in = NULL, *out = NULL;
const struct static_nodes_format *format = &static_nodes_format_human;
- char buf[4096];
- int ret = EXIT_SUCCESS;
+ int r, ret = EXIT_SUCCESS;
for (;;) {
int c, idx = 0, valid;
@@ -227,6 +226,13 @@ static int do_static_nodes(int argc, char *argv[])
goto finish;
}
+ r = mkdir_parents(output, 0755);
+ if (r < 0) {
+ fprintf(stderr, "Error: could not create parent directory for %s - %m.\n", output);
+ ret = EXIT_FAILURE;
+ goto finish;
+ }
+
out = fopen(output, "we");
if (out == NULL) {
fprintf(stderr, "Error: could not create %s - %m\n", output);