All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Landley <rob@landley.net>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, Jeff Layton <jlayton@redhat.com>,
	Jens Axboe <axboe@kernel.dk>, Stephen Warren <swarren@nvidia.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Jim Cromie <jim.cromie@gmail.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH 3/5] initmpfs v2: Move rootfs code from fs/ramfs/ to init/
Date: Tue, 16 Jul 2013 16:45:27 -0700 (PDT)	[thread overview]
Message-ID: <1374018312.367244@landley.net> (raw)
In-Reply-To: <1374018312.366617@landley.net>

From: Rob Landley <rob@landley.net>

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>
---

 fs/namespace.c        |    2 +-
 fs/ramfs/inode.c      |   32 +-------------------------------
 include/linux/init.h  |    1 +
 include/linux/ramfs.h |    2 +-
 init/do_mounts.c      |   32 ++++++++++++++++++++++++++++++++
 5 files changed, 36 insertions(+), 33 deletions(-)

--- initold/fs/namespace.c	2013-06-28 15:09:19.389872904 -0500
+++ initold2/fs/namespace.c	2013-06-28 15:16:05.261889820 -0500
@@ -17,7 +17,7 @@
 #include <linux/security.h>
 #include <linux/idr.h>
 #include <linux/acct.h>		/* acct_auto_close_mnt */
-#include <linux/ramfs.h>	/* init_rootfs */
+#include <linux/init.h>		/* init_rootfs */
 #include <linux/fs_struct.h>	/* get_fs_root et.al. */
 #include <linux/fsnotify.h>	/* fsnotify_vfsmount_delete */
 #include <linux/uaccess.h>
--- initold/fs/ramfs/inode.c	2013-06-28 15:15:37.549888666 -0500
+++ initold2/fs/ramfs/inode.c	2013-06-28 15:16:05.273889820 -0500
@@ -244,17 +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)
-{
-	static unsigned long once;
-
-	if (test_and_set_bit(1, &once))
-		return ERR_PTR(-ENODEV);
-
-	return mount_nodev(fs_type, flags, data, ramfs_fill_super);
-}
-
 static void ramfs_kill_sb(struct super_block *sb)
 {
 	kfree(sb->s_fs_info);
@@ -267,13 +256,8 @@
 	.kill_sb	= ramfs_kill_sb,
 	.fs_flags	= FS_USERNS_MOUNT,
 };
-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)
+int __init init_ramfs_fs(void)
 {
 	static unsigned long once;
 	int err;
@@ -292,17 +276,3 @@
 	return err;
 }
 module_init(init_ramfs_fs)
-
-int __init init_rootfs(void)
-{
-	int err = register_filesystem(&rootfs_fs_type);
-
-	if (err)
-		return err;
-
-	err = init_ramfs_fs();
-	if (err)
-		unregister_filesystem(&rootfs_fs_type);
-
-	return err;
-}
--- initold/include/linux/init.h	2013-06-28 15:09:19.517872909 -0500
+++ initold2/include/linux/init.h	2013-06-28 15:16:05.321889821 -0500
@@ -153,6 +153,7 @@
 void setup_arch(char **);
 void prepare_namespace(void);
 void __init load_default_modules(void);
+int __init init_rootfs(void);
 
 extern void (*late_time_init)(void);
 
--- initold/include/linux/ramfs.h	2013-06-28 15:09:19.537872910 -0500
+++ initold2/include/linux/ramfs.h	2013-06-28 15:16:05.513889832 -0500
@@ -25,7 +25,7 @@
 
 extern const struct file_operations ramfs_file_operations;
 extern const struct vm_operations_struct generic_file_vm_ops;
-extern int __init init_rootfs(void);
+extern int __init init_ramfs_fs(void);
 
 int ramfs_fill_super(struct super_block *sb, void *data, int silent);
 
--- initold/init/do_mounts.c	2013-06-28 15:09:19.585872913 -0500
+++ initold2/init/do_mounts.c	2013-06-28 15:16:05.561889831 -0500
@@ -26,6 +26,7 @@
 #include <linux/async.h>
 #include <linux/fs_struct.h>
 #include <linux/slab.h>
+#include <linux/ramfs.h>
 
 #include <linux/nfs_fs.h>
 #include <linux/nfs_fs_sb.h>
@@ -588,3 +589,34 @@
 	sys_mount(".", "/", NULL, MS_MOVE, NULL);
 	sys_chroot(".");
 }
+
+static struct dentry *rootfs_mount(struct file_system_type *fs_type,
+	int flags, const char *dev_name, void *data)
+{
+	static unsigned long once;
+
+	if (test_and_set_bit(1, &once))
+		return ERR_PTR(-ENODEV);
+
+	return mount_nodev(fs_type, flags, data, ramfs_fill_super);
+}
+
+static struct file_system_type rootfs_fs_type = {
+	.name		= "rootfs",
+	.mount		= rootfs_mount,
+	.kill_sb	= kill_litter_super,
+};
+
+int __init init_rootfs(void)
+{
+	int err = register_filesystem(&rootfs_fs_type);
+
+	if (err)
+		return err;
+
+	err = init_ramfs_fs();
+	if (err)
+		unregister_filesystem(&rootfs_fs_type);
+
+	return err;
+}
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index c24f1e1..3b9f114 100644

  parent reply	other threads:[~2013-07-16 23:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-16 23:45 [PATCH 0/5] initmpfs v2: use tmpfs instead of ramfs for rootfs Rob Landley
2013-07-16 23:45 ` Rob Landley
2013-07-16 23:45 ` Rob Landley
2013-07-16 23:45 ` [PATCH 1/5] initmpfs v2: replace MS_NOUSER in initramfs Rob Landley
2013-07-16 23:45 ` [PATCH 2/5] initmpfs v2: Move bdi setup from init_rootfs to init_ramfs Rob Landley
2013-07-16 23:45 ` Rob Landley [this message]
2013-07-16 23:45 ` [PATCH 4/5] initmpfs v2: Make rootfs use tmpfs when CONFIG_TMPFS enabled Rob Landley
2013-07-16 23:45   ` Rob Landley
2013-07-16 23:45 ` [PATCH 5/5] initmpfs v2: Use initramfs if rootfstype= or root= specified Rob Landley
2013-07-19 19:57   ` Andrew Morton
2013-07-26  4:12     ` Rob Landley
  -- strict thread matches above, loose matches on Subject: below --
2013-07-16 15:31 [PATCH 0/5] initmpfs v2: use tmpfs instead of ramfs for rootfs Rob Landley
2013-07-16 15:31 ` [PATCH 3/5] initmpfs v2: Move rootfs code from fs/ramfs/ to init/ Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374018312.367244@landley.net \
    --to=rob@landley.net \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jim.cromie@gmail.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=sam@ravnborg.org \
    --cc=swarren@nvidia.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.