Before: c /dev/cpu/microcode 0600 - - - 10:184 c /dev/fuse 0600 - - - 10:229 c /dev/btrfs-control 0600 - - - 10:234 c /dev/loop-control 0600 - - - 10:237 c /dev/snd/timer 0600 - - - 116:33 After: d /dev/cpu 0755 - - - c /dev/cpu/microcode 0600 - - - 10:184 c /dev/fuse 0600 - - - 10:229 c /dev/btrfs-control 0600 - - - 10:234 c /dev/loop-control 0600 - - - 10:237 d /dev/snd 0755 - - - c /dev/snd/timer 0600 - - - 116:33 --- tools/static-nodes.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tools/static-nodes.c b/tools/static-nodes.c index 65a36fc..b88e09c 100644 --- a/tools/static-nodes.c +++ b/tools/static-nodes.c @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <stddef.h> +#include <libgen.h> #include <getopt.h> #include <errno.h> #include <unistd.h> @@ -84,13 +85,27 @@ static const struct static_nodes_format static_nodes_format_human = { static int write_tmpfiles(FILE *out, char modname[], char devname[], char type, unsigned int maj, unsigned int min) { - int ret; + int ret = EXIT_SUCCESS; + char *dir; - ret = fprintf(out, "%c /dev/%s 0600 - - - %u:%u\n", type, devname, maj, min); - if (ret >= 0) - return EXIT_SUCCESS; - else + dir = strdup(devname); + if (!dir) return EXIT_FAILURE; + if (!streq(dirname(dir), ".")) { + ret = fprintf(out, "d /dev/%s 0755 - - -\n", dir); + if (ret < 0) { + ret = EXIT_FAILURE; + goto finish; + } + } + + ret = fprintf(out, "%c /dev/%s 0600 - - - %u:%u\n", type, devname, maj, min); + if (ret < 0) + ret = EXIT_FAILURE; + +finish: + free(dir); + return ret; } static const struct static_nodes_format static_nodes_format_tmpfiles = { -- 1.8.2.1 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html