summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-04-19 23:53:35 +0200
committerLucas De Marchi <lucas.de.marchi@gmail.com>2013-04-19 19:03:03 -0300
commit4905769de7cb35990c86279d9e079ff39ffdd72a (patch)
treef8544a83e83c8acf5af0f2bf165d8a28ed4b9afc
parent279b177de62cd9778ed6b111a11d93d8e18fa169 (diff)
downloadkmod-4905769de7cb35990c86279d9e079ff39ffdd72a.tar.gz
static-nodes: tmpfiles - also create parents directories of device nodes
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
-rw-r--r--tools/static-nodes.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/tools/static-nodes.c b/tools/static-nodes.c
index 65a36fc..1dec825 100644
--- a/tools/static-nodes.c
+++ b/tools/static-nodes.c
@@ -84,13 +84,21 @@ 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)
{
+ const char *dir;
int ret;
+ dir = strrchr(devname, '/');
+ if (dir) {
+ ret = fprintf(out, "d /dev/%.*s 0755 - - -\n", (int)(dir - devname), devname);
+ if (ret < 0)
+ return EXIT_FAILURE;
+ }
+
ret = fprintf(out, "%c /dev/%s 0600 - - - %u:%u\n", type, devname, maj, min);
- if (ret >= 0)
- return EXIT_SUCCESS;
- else
+ if (ret < 0)
return EXIT_FAILURE;
+
+ return EXIT_SUCCESS;
}
static const struct static_nodes_format static_nodes_format_tmpfiles = {