]> git.pld-linux.org Git - packages/kernel.git/blame - kernel-inittmpfs.patch
- conflicts with util-vserver tools with broken vprocunhide
[packages/kernel.git] / kernel-inittmpfs.patch
CommitLineData
e6775ab8 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"
f261bd33 10+ depends on TMPFS
e6775ab8 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@@ -6,6 +6,7 @@
28 #include <linux/delay.h>
29 #include <linux/string.h>
30 #include <linux/syscalls.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>
85@@ -482,6 +526,9 @@
86 initrd_end - initrd_start, 1);
87 if (!err) {
88 printk(" it is\n");
89+#ifdef CONFIG_EARLYUSERSPACE_ON_TMPFS
90+ overmount_rootfs();
91+#endif /* CONFIG_EARLYUSERSPACE_ON_TMPFS */
92 unpack_to_rootfs((char *)initrd_start,
93 initrd_end - initrd_start, 0);
94 free_initrd_mem(initrd_start, initrd_end);
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@@ -2136,7 +2136,7 @@
114 };
115 static struct vfsmount *shm_mnt;
116
117-static int __init init_tmpfs(void)
118+int __init init_tmpfs(void)
119 {
120 int error;
121
122@@ -2169,7 +2169,12 @@
123 shm_mnt = ERR_PTR(error);
124 return error;
125 }
126+/* Don't do this if we are calling it early explicity */
127+#ifndef CONFIG_EARLYUSERSPACE_ON_TMPFS
128+/* If CONFIG_EARLYUSERSPACE_ON_TMPFS is set then we will interpose
129+ * ramfs so this will get called explicitly and early */
130 module_init(init_tmpfs)
131+#endif /* !CONFIG_EARLYUSERSPACE_ON_TMPFS */
132
133 /*
134 * shmem_file_setup - get an unlinked file living in tmpfs
This page took 0.05852 seconds and 4 git commands to generate.