Commit 57f150a58c40cda598c31af8bceb8598f43c3e5f
Committed by
Linus Torvalds
1 parent
4bbee76bc9
Exists in
master
and in
20 other branches
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>
Showing 5 changed files with 36 additions and 33 deletions Side-by-side Diff
fs/namespace.c
... | ... | @@ -17,7 +17,7 @@ |
17 | 17 | #include <linux/security.h> |
18 | 18 | #include <linux/idr.h> |
19 | 19 | #include <linux/acct.h> /* acct_auto_close_mnt */ |
20 | -#include <linux/ramfs.h> /* init_rootfs */ | |
20 | +#include <linux/init.h> /* init_rootfs */ | |
21 | 21 | #include <linux/fs_struct.h> /* get_fs_root et.al. */ |
22 | 22 | #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */ |
23 | 23 | #include <linux/uaccess.h> |
fs/ramfs/inode.c
... | ... | @@ -244,17 +244,6 @@ |
244 | 244 | return mount_nodev(fs_type, flags, data, ramfs_fill_super); |
245 | 245 | } |
246 | 246 | |
247 | -static 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 | - | |
258 | 247 | static void ramfs_kill_sb(struct super_block *sb) |
259 | 248 | { |
260 | 249 | kfree(sb->s_fs_info); |
261 | 250 | |
... | ... | @@ -267,13 +256,8 @@ |
267 | 256 | .kill_sb = ramfs_kill_sb, |
268 | 257 | .fs_flags = FS_USERNS_MOUNT, |
269 | 258 | }; |
270 | -static struct file_system_type rootfs_fs_type = { | |
271 | - .name = "rootfs", | |
272 | - .mount = rootfs_mount, | |
273 | - .kill_sb = kill_litter_super, | |
274 | -}; | |
275 | 259 | |
276 | -static int __init init_ramfs_fs(void) | |
260 | +int __init init_ramfs_fs(void) | |
277 | 261 | { |
278 | 262 | static unsigned long once; |
279 | 263 | int err; |
... | ... | @@ -292,18 +276,4 @@ |
292 | 276 | return err; |
293 | 277 | } |
294 | 278 | module_init(init_ramfs_fs) |
295 | - | |
296 | -int __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 | -} |
include/linux/init.h
include/linux/ramfs.h
... | ... | @@ -25,7 +25,7 @@ |
25 | 25 | |
26 | 26 | extern const struct file_operations ramfs_file_operations; |
27 | 27 | extern const struct vm_operations_struct generic_file_vm_ops; |
28 | -extern int __init init_rootfs(void); | |
28 | +extern int __init init_ramfs_fs(void); | |
29 | 29 | |
30 | 30 | int ramfs_fill_super(struct super_block *sb, void *data, int silent); |
31 | 31 |
init/do_mounts.c
... | ... | @@ -26,6 +26,7 @@ |
26 | 26 | #include <linux/async.h> |
27 | 27 | #include <linux/fs_struct.h> |
28 | 28 | #include <linux/slab.h> |
29 | +#include <linux/ramfs.h> | |
29 | 30 | |
30 | 31 | #include <linux/nfs_fs.h> |
31 | 32 | #include <linux/nfs_fs_sb.h> |
... | ... | @@ -587,5 +588,36 @@ |
587 | 588 | devtmpfs_mount("dev"); |
588 | 589 | sys_mount(".", "/", NULL, MS_MOVE, NULL); |
589 | 590 | sys_chroot("."); |
591 | +} | |
592 | + | |
593 | +static 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 | + | |
604 | +static struct file_system_type rootfs_fs_type = { | |
605 | + .name = "rootfs", | |
606 | + .mount = rootfs_mount, | |
607 | + .kill_sb = kill_litter_super, | |
608 | +}; | |
609 | + | |
610 | +int __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; | |
590 | 622 | } |