summaryrefslogtreecommitdiff
path: root/kernel-inittmpfs.patch
blob: a89cb38df9dca4e741bb17805370884bfda3b268 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
diff -ruw linux-2.6.30.orig/fs/Kconfig linux-2.6.30/fs/Kconfig
--- linux-2.6.30.orig/fs/Kconfig	2009-02-12 17:51:15.000000000 +0000
+++ linux-2.6.30/fs/Kconfig	2009-02-13 12:01:55.000000000 +0000
@@ -724,6 +724,25 @@
 
 	  If you don't know what Access Control Lists are, say N.
 
+config TMPFS_ROOT
+	bool "Use tmpfs instead of ramfs for initramfs"
+	depends on TMPFS && SHMEM
+	default y
+	help
+	  This replaces the ramfs used for unpacking the cpio images
+	  with tmpfs.
+
+config RAMFS
+	  bool "Ramfs file system support" if TMPFS_ROOT
+	  default n
+	---help---
+	  Ramfs is a file system which keeps all files in RAM. Unlike tmpfs,
+	  it cannot be swapped to disk, and it has the risk of deadlocking
+	  the system by using all memory.
+
+	  Ramfs is used for booting the system and unpacking the cpio if
+	  TMPFS_ROOT is not set.
+
 config HUGETLBFS
 	bool "HugeTLB file system support"
 	depends on X86 || IA64 || PPC64 || SPARC64 || (SUPERH && MMU) || \
diff -ruw linux-2.6.30.orig/fs/ramfs/inode.c linux-2.6.30/fs/ramfs/inode.c
--- linux-2.6.30.orig/fs/ramfs/inode.c	2009-02-12 17:51:15.000000000 +0000
+++ linux-2.6.30/fs/ramfs/inode.c	2009-02-13 11:30:30.000000000 +0000
@@ -244,12 +244,6 @@
 	return mount_nodev(fs_type, flags, data, ramfs_fill_super);
 }
 
-static struct dentry *rootfs_mount(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
-{
-	return mount_nodev(fs_type, flags|MS_NOUSER, data, ramfs_fill_super);
-}
-
 static void ramfs_kill_sb(struct super_block *sb)
 {
 	kfree(sb->s_fs_info);
@@ -261,18 +255,20 @@
 	.mount		= ramfs_mount,
 	.kill_sb	= ramfs_kill_sb,
 };
+
+#ifndef CONFIG_TMPFS_ROOT
+static struct dentry *rootfs_mount(struct file_system_type *fs_type,
+	int flags, const char *dev_name, void *data)
+{
+	return mount_nodev(fs_type, flags|MS_NOUSER, data, ramfs_fill_super);
+}
+
 static struct file_system_type rootfs_fs_type = {
 	.name		= "rootfs",
 	.mount		= rootfs_mount,
 	.kill_sb	= kill_litter_super,
 };
 
-static int __init init_ramfs_fs(void)
-{
-	return register_filesystem(&ramfs_fs_type);
-}
-module_init(init_ramfs_fs)
-
 int __init init_rootfs(void)
 {
 	int err;
@@ -287,3 +283,12 @@
 
 	return err;
 }
+#endif
+
+static int __init init_ramfs_fs(void)
+{
+	return register_filesystem(&ramfs_fs_type);
+}
+module_init(init_ramfs_fs)
+
+
diff -ruw linux-2.6.30.orig/mm/shmem.c linux-2.6.30/mm/shmem.c
--- linux-2.6.30.orig/mm/shmem.c	2009-02-12 17:51:15.000000000 +0000
+++ linux-2.6.30/mm/shmem.c	2009-02-13 11:42:02.000000000 +0000
@@ -86,7 +86,7 @@
 #ifdef CONFIG_TMPFS
 static unsigned long shmem_default_max_blocks(void)
 {
-	return totalram_pages / 2;
+	return totalram_pages / 10 * 9;
 }
 
 static unsigned long shmem_default_max_inodes(void)
@@ -2369,6 +2369,10 @@
 
 static int shmem_init_inodecache(void)
 {
+#ifdef CONFIG_TMPFS_ROOT
+ if (shmem_inode_cachep)
+ return 0;
+#endif
 	shmem_inode_cachep = kmem_cache_create("shmem_inode_cache",
 				sizeof(struct shmem_inode_info),
 				0, SLAB_PANIC, init_once);
@@ -2587,6 +2591,27 @@
 }
 EXPORT_SYMBOL_GPL(shmem_file_setup);
 
+#ifdef CONFIG_TMPFS_ROOT
+
+
+
+
+
+
+static struct file_system_type rootfs_fs_type = {
+ .name = "rootfs",
+ .mount = shmem_mount,
+ .kill_sb = kill_litter_super,
+};
+
+int __init init_rootfs(void)
+{
+ if (shmem_init_inodecache())
+ panic("Can't initialize shm inode cache");
+ return register_filesystem(&rootfs_fs_type);
+}
+#endif
+
 /**
  * shmem_zero_setup - setup a shared anonymous mapping
  * @vma: the vma to be mmapped is prepared by do_mmap_pgoff