diff -ru busybox-1.4.1.orig/init/Config.in busybox-1.4.1/init/Config.in --- busybox-1.4.1.orig/init/Config.in 2007-01-24 21:34:50.000000000 +0000 +++ busybox-1.4.1/init/Config.in 2007-02-28 11:35:17.000000000 +0000 @@ -68,6 +68,17 @@ This does not apply to initramfs, which runs /init as PID 1 and requires no special support. +config FEATURE_INIT_UDEV + bool "Support creating a tmpfs file system on /dev and creating basic device nodes /dev/console and /dev/null" + default n + depends on INIT + help + If this option is enabled and the file /dev/console does not exist then + init will mount a tmpfs file system on /dev and create the basic device nodes + /dev/console and /dev/null. This allows a system to boot and run without any + device nodes in the root file system. The system startup scripts can create additional + device nodes as needed or a full udev implementation can take over. + config HALT bool "poweroff, halt, and reboot" default y diff -ru busybox-1.4.1.orig/init/init.c busybox-1.4.1/init/init.c --- busybox-1.4.1.orig/init/init.c 2007-01-24 21:34:50.000000000 +0000 +++ busybox-1.4.1/init/init.c 2007-02-28 11:52:32.000000000 +0000 @@ -969,6 +969,29 @@ } #endif /* FEATURE_USE_INITTAB */ +#if ENABLE_FEATURE_INIT_UDEV +int udev_create(void){ + int e; + + if((e = mount("/tmpfs", "/dev", "tmpfs", 0, 0))) + return e; + + if((e = mknod("/dev/console", S_IFCHR | 0600, makedev(5, 1)))){ + umount("/dev"); + return e; + } + + if((e = mknod("/dev/null", S_IFCHR | 0666, makedev(1, 3)))){ + umount("/dev"); + return e; + } + chmod("/dev", 0755); + chmod("/dev/null", 0666); + + return 0; +} +#endif + int init_main(int argc, char **argv) { struct init_action *a; @@ -1003,6 +1026,11 @@ init_reboot(RB_DISABLE_CAD); #endif +#if ENABLE_FEATURE_INIT_UDEV + if(access("/dev/console", R_OK | W_OK)) + udev_create(); +#endif + /* Figure out where the default console should be */ console_init();