Commit 16203a7a9422315bc929461503e3a046459ea5ff
Committed by
Linus Torvalds
1 parent
57f150a58c
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
initmpfs: make rootfs use tmpfs when CONFIG_TMPFS enabled
Conditionally call the appropriate fs_init function and fill_super functions. Add a use once guard to shmem_init() to simply succeed on a second call. (Note that IS_ENABLED() is a compile time constant so dead code elimination removes unused function calls when CONFIG_TMPFS is disabled.) Signed-off-by: Rob Landley <rob@landley.net> Cc: Jeff Layton <jlayton@redhat.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Stephen Warren <swarren@nvidia.com> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Jim Cromie <jim.cromie@gmail.com> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 2 changed files with 12 additions and 2 deletions Side-by-side Diff
init/do_mounts.c
... | ... | @@ -27,6 +27,7 @@ |
27 | 27 | #include <linux/fs_struct.h> |
28 | 28 | #include <linux/slab.h> |
29 | 29 | #include <linux/ramfs.h> |
30 | +#include <linux/shmem_fs.h> | |
30 | 31 | |
31 | 32 | #include <linux/nfs_fs.h> |
32 | 33 | #include <linux/nfs_fs_sb.h> |
... | ... | @@ -598,7 +599,8 @@ |
598 | 599 | if (test_and_set_bit(0, &once)) |
599 | 600 | return ERR_PTR(-ENODEV); |
600 | 601 | |
601 | - return mount_nodev(fs_type, flags, data, ramfs_fill_super); | |
602 | + return mount_nodev(fs_type, flags, data, | |
603 | + IS_ENABLED(CONFIG_TMPFS) ? shmem_fill_super : ramfs_fill_super); | |
602 | 604 | } |
603 | 605 | |
604 | 606 | static struct file_system_type rootfs_fs_type = { |
... | ... | @@ -614,7 +616,11 @@ |
614 | 616 | if (err) |
615 | 617 | return err; |
616 | 618 | |
617 | - err = init_ramfs_fs(); | |
619 | + if (IS_ENABLED(CONFIG_TMPFS)) | |
620 | + err = shmem_init(); | |
621 | + else | |
622 | + err = init_ramfs_fs(); | |
623 | + | |
618 | 624 | if (err) |
619 | 625 | unregister_filesystem(&rootfs_fs_type); |
620 | 626 |
mm/shmem.c