linux: update to 4.13.1
[openadk.git] / target / linux / patches / 3.16.43 / initramfs-nosizelimit.patch
blob40d2f6bd8b02091d8a256735edf94f3e2aeadfe7
1 From 9a18df7a71bfa620b1278777d64783a359d7eb4e Mon Sep 17 00:00:00 2001
2 From: Thorsten Glaser <tg@mirbsd.org>
3 Date: Sun, 4 May 2014 01:37:54 +0200
4 Subject: [PATCH] mount tmpfs-as-rootfs (initramfs) with -o
5 nr_blocks=0,nr_inodes=0
7 I would have preferred to write this patch to be able to pass
8 rootflags=nr_blocks=0,nr_inodes=0 on the kernel command line,
9 and then hand these rootflags over to the initramfs (tmpfs)
10 mount in the same way the kernel hands them over to the block
11 device rootfs mount. But at least the Debian/m68k initrd also
12 parses $rootflags from the environment and adds it to the call
13 to the user-space mount for the eventual root device, which
14 would make the kernel command line rootflags option be used in
15 both places (tmpfs and e.g. ext4) which is guaranteed to error
16 out in at least one of them.
18 This change is intended to aid people in a setup where the
19 initrd is the final root filesystem, i.e. not mounted over.
20 This is especially useful in automated tests running on qemu
21 for boards with constrained memory (e.g. 64 MiB on sh4).
23 Considering that the initramfs is normally emptied out then
24 overmounted, this change is probably safe for setups where
25 initramfs just hosts early userspace, too, since the tmpfs
26 backing it is not accessible any more later on, AFAICT.
28 Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
29 ---
30 init/do_mounts.c | 4 ++++
31 1 file changed, 4 insertions(+)
33 diff --git a/init/do_mounts.c b/init/do_mounts.c
34 index 82f2288..55a4cfe 100644
35 --- a/init/do_mounts.c
36 +++ b/init/do_mounts.c
37 @@ -594,6 +594,7 @@ out:
40 static bool is_tmpfs;
41 +static char tmpfs_rootflags[] = "nr_blocks=0,nr_inodes=0";
42 static struct dentry *rootfs_mount(struct file_system_type *fs_type,
43 int flags, const char *dev_name, void *data)
45 @@ -606,6 +607,9 @@ static struct dentry *rootfs_mount(struct file_system_type *fs_type,
46 if (IS_ENABLED(CONFIG_TMPFS) && is_tmpfs)
47 fill = shmem_fill_super;
49 + if (is_tmpfs)
50 + data = tmpfs_rootflags;
52 return mount_nodev(fs_type, flags, data, fill);
55 --
56 2.0.0.rc0