From 9f83bbe788824dc98f96070d53a4db4d76671b6c Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Mon, 11 Aug 2008 18:03:52 -0300 Subject: [PATCH] Allow creation of device nodes from configuration file Using command "mknod", same syntax as mknod(1) Signed-off-by: Claudio Matsuoka --- finit-alt.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/finit-alt.c b/finit-alt.c index 50de46aa..42c5e516 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -189,7 +189,6 @@ int main() char username[USERNAME_SIZE] = DEFUSER; char hostname[HOSTNAME_SIZE] = "eviltwin"; char cmd[CMD_SIZE]; - int mountdev = 0; #ifdef USE_ETC_RESOLVCONF_RUN DIR *dir; struct dirent *d; @@ -250,6 +249,17 @@ int main() fclose(f); } + setsid(); + + /* + * Mount filesystems + */ +#ifdef REMOUNT_ROOTFS_RW + system("/bin/mount -n -o remount,rw /"); +#endif + umask(0); + + /* * Parse configuration file */ @@ -285,26 +295,19 @@ int main() continue; } if (MATCH_CMD(line, "mountdev", x)) { - mountdev = 1; + mount("none", "/dev", "tmpfs", 0, "mode=0755"); + continue; + } + if (MATCH_CMD(line, "mknod ", x)) { + strcpy(cmd, "/bin/mknod "); + build_cmd(cmd, x, CMD_SIZE); + system(cmd); continue; } } fclose(f); } - setsid(); - - /* - * Mount filesystems - */ -#ifdef REMOUNT_ROOTFS_RW - system("/bin/mount -n -o remount,rw /"); -#endif - umask(0); - - if (mountdev) - mount("none", "/dev", "tmpfs", 0, "mode=0755"); - #ifdef MAKE_DEVICES mkdir("/dev/shm", 0755); mkdir("/dev/pts", 0755);