]> git.pld-linux.org Git - packages/kernel.git/blame - kernel-inittmpfs.patch
- add kvm/api.txt documentation
[packages/kernel.git] / kernel-inittmpfs.patch
CommitLineData
2380c486
JR
1diff -ur linux-2.6.14.orig/fs/Kconfig linux-2.6.14/fs/Kconfig
2--- linux-2.6.14.orig/fs/Kconfig 2005-09-11 03:19:07.000000000 +0000
3+++ linux-2.6.14/fs/Kconfig 2005-09-11 03:19:42.000000000 +0000
4@@ -805,6 +805,18 @@
5
6 See <file:Documentation/filesystems/tmpfs.txt> for details.
7
8+config EARLYUSERSPACE_ON_TMPFS
9+ bool "Unpack the early userspace onto tmpfs"
10+ depends on TMPFS
11+ default y
12+ help
13+ Use this to have your early userspace placed (decompressed)
14+ onto tmpfs as opposed ramfs. This will allow you to
15+ restrict the size of your root-filesystem and it will also
16+ be swappable.
17+
18+ If unsure, say Y.
19+
20 config HUGETLBFS
21 bool "HugeTLB file system support"
22 depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || X86_64 || BROKEN
23Only in linux-2.6.14/fs: Kconfig.orig
24diff -ur linux-2.6.14.orig/init/initramfs.c linux-2.6.14/init/initramfs.c
25--- linux-2.6.14.orig/init/initramfs.c 2005-08-28 23:41:01.000000000 +0000
26+++ linux-2.6.14/init/initramfs.c 2005-09-11 03:19:42.000000000 +0000
27@@ -7,6 +7,7 @@
28 #include <linux/string.h>
29 #include <linux/syscalls.h>
30 #include <linux/utime.h>
31+#include <asm/uaccess.h>
32
33 static __initdata char *message;
34 static void __init error(char *x)
35@@ -463,6 +464,49 @@
36 return message;
37 }
38
39+/* If we want the rootfs on initramfs so we mount initramfs over the
40+ * rootfs before we unpack it. The little dance we do by creating a
41+ * pivot point and moving the root to that is in fact necessary
42+ * because lookups of "." don't resolve mountpoints.
43+ */
44+static inline void __init overmount_rootfs(void)
45+ {
46+#ifdef CONFIG_EARLYUSERSPACE_ON_TMPFS
47+ int init_tmpfs(void);
48+ int (*initfunc)(void) = init_tmpfs;
49+ mm_segment_t oldfs;
50+ char pivot[] = "/pivot";
51+
52+ /* Explicitly go and init the overmount fs early (long-term
53+ * the need for this will probably go away. */
54+
55+ if (initfunc())
56+ goto err;
57+
58+ oldfs = get_fs();
59+ set_fs(KERNEL_DS);
60+
61+ if (sys_mkdir(pivot, 0700) < 0)
62+ goto err;
63+ if (sys_mount("tmpfs", pivot, "tmpfs", 0, "size=95%"))
64+ goto err;
65+
66+ /* Below here errors are unlikely and icky to deal with. */
67+ sys_chdir(pivot);
68+ sys_mount(".", "/", NULL, MS_MOVE, NULL);
69+ sys_chdir(".");
70+ sys_chroot(".");
71+ printk(KERN_INFO "Overmounted tmpfs\n");
72+ goto out;
73+
74+ err:
75+ printk(KERN_ERR "Overmount error\n");
76+
77+ out:
78+ set_fs(oldfs);
79+#endif /* CONFIG_EARLYUSERSPACE_ON_TMPFS */
80+}
81+
82 extern char __initramfs_start[], __initramfs_end[];
83 #ifdef CONFIG_BLK_DEV_INITRD
84 #include <linux/initrd.h>
dece6358
AM
85@@ -619,6 +619,9 @@
86 #ifdef CONFIG_BLK_DEV_RAM
87 int fd;
88 printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n");
2380c486 89+#ifdef CONFIG_EARLYUSERSPACE_ON_TMPFS
dece6358 90+ overmount_rootfs();
2380c486 91+#endif /* CONFIG_EARLYUSERSPACE_ON_TMPFS */
dece6358
AM
92 err = unpack_to_rootfs((char *)initrd_start,
93 initrd_end - initrd_start);
94 if (!err) {
2380c486
JR
95diff -ur linux-2.6.14.orig/init/main.c linux-2.6.14/init/main.c
96--- linux-2.6.14.orig/init/main.c 2005-09-11 03:19:07.000000000 +0000
97+++ linux-2.6.14/init/main.c 2005-09-11 03:22:43.000000000 +0000
98@@ -701,6 +701,11 @@
99 if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
100 ramdisk_execute_command = NULL;
101 prepare_namespace();
102+#ifdef CONFIG_EARLYUSERSPACE_ON_TMPFS
103+ int init_tmpfs(void);
104+ int (*initfunc)(void) = init_tmpfs;
105+ initfunc();
106+#endif /* CONFIG_EARLYUSERSPACE_ON_TMPFS */
107 }
108
109 /*
110diff -ur linux-2.6.14.orig/mm/shmem.c linux-2.6.14/mm/shmem.c
111--- linux-2.6.14.orig/mm/shmem.c 2005-09-11 03:19:07.000000000 +0000
112+++ linux-2.6.14/mm/shmem.c 2005-09-11 03:19:42.000000000 +0000
113@@ -2504,7 +2504,7 @@
114 .kill_sb = kill_litter_super,
115 };
116
117-static int __init init_tmpfs(void)
118+int __init init_tmpfs(void)
119 {
120 int error;
121
122@@ -2672,4 +2672,9 @@
123 return 0;
124 }
125
126-module_init(init_tmpfs)
127+/* Don't do this if we are calling it early explicity */
128+#ifndef CONFIG_EARLYUSERSPACE_ON_TMPFS
129+/* If CONFIG_EARLYUSERSPACE_ON_TMPFS is set then we will interpose
130+ * ramfs so this will get called explicitly and early */
131+ module_init(init_tmpfs)
132+#endif /* !CONFIG_EARLYUSERSPACE_ON_TMPFS */
133
This page took 0.196247 seconds and 4 git commands to generate.