summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-09-11 17:26:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:37 -0400
commit57f150a58c40cda598c31af8bceb8598f43c3e5f (patch)
treefde3e7fc48c97f0db5b3975fd74e12773f423fe2
parent4bbee76bc986af326be0a84ad661000cf89b29f6 (diff)
initmpfs: move rootfs code from fs/ramfs/ to init/
When the rootfs code was a wrapper around ramfs, having them in the same file made sense. Now that it can wrap another filesystem type, move it in with the init code instead. This also allows a subsequent patch to access rootfstype= command line arg. 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>
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/ramfs/inode.c32
-rw-r--r--include/linux/init.h1
-rw-r--r--include/linux/ramfs.h2
-rw-r--r--init/do_mounts.c32
5 files changed, 36 insertions, 33 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 25845d1b300b..da5c49483430 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -17,7 +17,7 @@
17#include <linux/security.h> 17#include <linux/security.h>
18#include <linux/idr.h> 18#include <linux/idr.h>
19#include <linux/acct.h> /* acct_auto_close_mnt */ 19#include <linux/acct.h> /* acct_auto_close_mnt */
20#include <linux/ramfs.h> /* init_rootfs */ 20#include <linux/init.h> /* init_rootfs */
21#include <linux/fs_struct.h> /* get_fs_root et.al. */ 21#include <linux/fs_struct.h> /* get_fs_root et.al. */
22#include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */ 22#include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
23#include <linux/uaccess.h> 23#include <linux/uaccess.h>
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index fb99863598be..39d14659a8d3 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -244,17 +244,6 @@ struct dentry *ramfs_mount(struct file_system_type *fs_type,
244 return mount_nodev(fs_type, flags, data, ramfs_fill_super); 244 return mount_nodev(fs_type, flags, data, ramfs_fill_super);
245} 245}
246 246
247static struct dentry *rootfs_mount(struct file_system_type *fs_type,
248 int flags, const char *dev_name, void *data)
249{
250 static unsigned long once;
251
252 if (test_and_set_bit(0, &once))
253 return ERR_PTR(-ENODEV);
254
255 return mount_nodev(fs_type, flags, data, ramfs_fill_super);
256}
257
258static void ramfs_kill_sb(struct super_block *sb) 247static void ramfs_kill_sb(struct super_block *sb)
259{ 248{
260 kfree(sb->s_fs_info); 249 kfree(sb->s_fs_info);
@@ -267,13 +256,8 @@ static struct file_system_type ramfs_fs_type = {
267 .kill_sb = ramfs_kill_sb, 256 .kill_sb = ramfs_kill_sb,
268 .fs_flags = FS_USERNS_MOUNT, 257 .fs_flags = FS_USERNS_MOUNT,
269}; 258};
270static struct file_system_type rootfs_fs_type = {
271 .name = "rootfs",
272 .mount = rootfs_mount,
273 .kill_sb = kill_litter_super,
274};
275 259
276static int __init init_ramfs_fs(void) 260int __init init_ramfs_fs(void)
277{ 261{
278 static unsigned long once; 262 static unsigned long once;
279 int err; 263 int err;
@@ -292,17 +276,3 @@ static int __init init_ramfs_fs(void)
292 return err; 276 return err;
293} 277}
294module_init(init_ramfs_fs) 278module_init(init_ramfs_fs)
295
296int __init init_rootfs(void)
297{
298 int err = register_filesystem(&rootfs_fs_type);
299
300 if (err)
301 return err;
302
303 err = init_ramfs_fs();
304 if (err)
305 unregister_filesystem(&rootfs_fs_type);
306
307 return err;
308}
diff --git a/include/linux/init.h b/include/linux/init.h
index e73f2b708525..f1c27a71d03c 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -153,6 +153,7 @@ extern unsigned int reset_devices;
153void setup_arch(char **); 153void setup_arch(char **);
154void prepare_namespace(void); 154void prepare_namespace(void);
155void __init load_default_modules(void); 155void __init load_default_modules(void);
156int __init init_rootfs(void);
156 157
157extern void (*late_time_init)(void); 158extern void (*late_time_init)(void);
158 159
diff --git a/include/linux/ramfs.h b/include/linux/ramfs.h
index 69e37c2d1ea5..753207c8ce20 100644
--- a/include/linux/ramfs.h
+++ b/include/linux/ramfs.h
@@ -25,7 +25,7 @@ extern int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma);
25 25
26extern const struct file_operations ramfs_file_operations; 26extern const struct file_operations ramfs_file_operations;
27extern const struct vm_operations_struct generic_file_vm_ops; 27extern const struct vm_operations_struct generic_file_vm_ops;
28extern int __init init_rootfs(void); 28extern int __init init_ramfs_fs(void);
29 29
30int ramfs_fill_super(struct super_block *sb, void *data, int silent); 30int ramfs_fill_super(struct super_block *sb, void *data, int silent);
31 31
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 816014c4627e..5d8d48fd0ee4 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -26,6 +26,7 @@
26#include <linux/async.h> 26#include <linux/async.h>
27#include <linux/fs_struct.h> 27#include <linux/fs_struct.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/ramfs.h>
29 30
30#include <linux/nfs_fs.h> 31#include <linux/nfs_fs.h>
31#include <linux/nfs_fs_sb.h> 32#include <linux/nfs_fs_sb.h>
@@ -588,3 +589,34 @@ out:
588 sys_mount(".", "/", NULL, MS_MOVE, NULL); 589 sys_mount(".", "/", NULL, MS_MOVE, NULL);
589 sys_chroot("."); 590 sys_chroot(".");
590} 591}
592
593static struct dentry *rootfs_mount(struct file_system_type *fs_type,
594 int flags, const char *dev_name, void *data)
595{
596 static unsigned long once;
597
598 if (test_and_set_bit(0, &once))
599 return ERR_PTR(-ENODEV);
600
601 return mount_nodev(fs_type, flags, data, ramfs_fill_super);
602}
603
604static struct file_system_type rootfs_fs_type = {
605 .name = "rootfs",
606 .mount = rootfs_mount,
607 .kill_sb = kill_litter_super,
608};
609
610int __init init_rootfs(void)
611{
612 int err = register_filesystem(&rootfs_fs_type);
613
614 if (err)
615 return err;
616
617 err = init_ramfs_fs();
618 if (err)
619 unregister_filesystem(&rootfs_fs_type);
620
621 return err;
622}