diff -urN linux-2.6.30/init/do_mounts.c linux-2.6.30.fli4l/init/do_mounts.c --- linux-2.6.30/init/do_mounts.c 2009-06-10 05:05:27.000000000 +0200 +++ linux-2.6.30.fli4l/init/do_mounts.c 2009-06-10 08:49:01.565079695 +0200 @@ -394,6 +394,14 @@ root_device_name += 5; } +#ifdef CONFIG_INIT_TMPFS + { + extern int populate_rootfs(void); + if (populate_rootfs()) + goto out; + } +#endif + if (initrd_load()) goto out; diff -urN linux-2.6.30/init/initramfs.c linux-2.6.30.fli4l/init/initramfs.c --- linux-2.6.30/init/initramfs.c 2009-06-10 05:05:27.000000000 +0200 +++ linux-2.6.30.fli4l/init/initramfs.c 2009-06-10 09:01:09.896080627 +0200 @@ -565,12 +565,78 @@ } #endif +#ifdef CONFIG_INIT_TMPFS +static char __initdata tmpfs_options[64] = "mode=755"; /* options passed to tmpfs */ +int __initdata first_populate_rootfs_invocation = 1; +int __init mount_tmpfs_root(void); +extern int root_mountflags; + +static int __init inittmpfs_options(char *str) +{ + strncpy(tmpfs_options,str,63); + tmpfs_options[63] = 0; + return 1; +} + +__setup("inittmpfs=", inittmpfs_options); + +/* + * Mount a root tmpfs. Return 0 on success; -1 on failure. + */ +int init_tmpfs (void); +int __init mount_tmpfs_root(void) + { + int err; + int tmpfs_root_mountflags = root_mountflags; + + /* create mount point */ + if ( (err = sys_mkdir("/tmp_root", 0755)) < 0) { + printk(KERN_ERR "INITRAMFS: unable to create mountpoint /tmp_root. (%d)\n", err); + return -1; + } + + printk ("INITRAMFS: Trying to mount tmpfs using options '%s'.\n", tmpfs_options); + /* always mount rw,verbose */ + tmpfs_root_mountflags |= MS_VERBOSE; + tmpfs_root_mountflags &= ~MS_RDONLY; + err = sys_mount("tmpfs", "/tmp_root", "tmpfs", tmpfs_root_mountflags, + tmpfs_options); + if (err) { + (void)sys_rmdir("/tmp_root"); + printk(KERN_ERR "INITRAMFS: unable to mount tmpfs filesystem (%d), using normal ramfs.\n", err); + return -1; + } + printk ("INITRAMFS: tmpfs mounted.\n"); + if ( (err = sys_chdir("/tmp_root")) < 0) + printk(KERN_ERR "INITRAMFS: unable change to new root (%d).\n", err); + return 0; +} + +int __init populate_rootfs(void) +{ + char *err; + if (first_populate_rootfs_invocation) { + err = unpack_to_rootfs(__initramfs_start, + __initramfs_end - __initramfs_start); + if (err) + panic(err); + if (initrd_start) + printk(KERN_INFO "INITRAMFS: delaying decompression of initramfs to make use of tmpfs...\n"); + first_populate_rootfs_invocation = 0; + return 0; + } else { + if (initrd_start) + mount_tmpfs_root(); + } +#else + static int __init populate_rootfs(void) { char *err = unpack_to_rootfs(__initramfs_start, __initramfs_end - __initramfs_start); if (err) panic(err); /* Failed to decompress INTERNAL initramfs */ +#endif /* CONFIG_INIT_TMPFS */ if (initrd_start) { #ifdef CONFIG_BLK_DEV_RAM int fd; @@ -579,7 +645,11 @@ initrd_end - initrd_start); if (!err) { free_initrd(); - return 0; +#ifdef CONFIG_INIT_TMPFS + return 1; +#else + return 0; +#endif /* CONFIG_INIT_TMPFS */ } else { clean_rootfs(); unpack_to_rootfs(__initramfs_start, diff -urN linux-2.6.30/init/Kconfig linux-2.6.30.fli4l/init/Kconfig --- linux-2.6.30/init/Kconfig 2009-06-10 05:05:27.000000000 +0200 +++ linux-2.6.30.fli4l/init/Kconfig 2009-06-10 08:49:01.568084538 +0200 @@ -933,6 +933,15 @@ by some high performance threaded applications. Disabling this option saves about 7k. +config INIT_TMPFS + bool "Use tmpfs for initial ramfs" if EMBEDDED + default y + depends on TMPFS && BLK_DEV_INITRD + help + Use tmpfs for initial ramdisk. To achieve this the cpio archive for + the initial ram is extracted at the end of the boot process. If you + need the contents of the archive earlier you can't use this. + config VM_EVENT_COUNTERS default y bool "Enable VM event counters for /proc/vmstat" if EMBEDDED