public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2] init: replace sys_mount() to do_mount()
Date: Tue, 17 Aug 2010 23:38:09 +0900	[thread overview]
Message-ID: <1282055889-6135-1-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <201008171541.47078.arnd@arndb.de>

sys_mount() just copies all (string) arguments from user space to kernel
and calls do_mount(). In this case we have all args in kernel already so
there is no need to call sys_mount(). One thing we should take care is
'data' have to be in a page unless it is NULL. Do it manually.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---

I found 3 more calls in init/do_mounts_initrd.c and merged them. Please
apply this instead.

2010-08-17 (Tue), 15:41 +0200, Arnd Bergmann:
> Maybe you can fix that as well in the same patch and move this safeguard
> into the copy_mount_options() function? I guess ideally we'd even mark
> the arguments to do_mount() as pointers to const, but that might create
> an excessive amount of churn.

Arnd, thanks for reviewing and the suggestion but I think that should be
in a different patch (set).

 init/do_mounts.c        |   18 ++++++++++++++++--
 init/do_mounts_initrd.c |    6 +++---
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/init/do_mounts.c b/init/do_mounts.c
index 02e3ca4..8eabff6 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -217,7 +217,21 @@ static void __init get_fs_names(char *page)

 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
 {
-	int err = sys_mount(name, "/root", fs, flags, data);
+	int err;
+	unsigned long data_page = 0;
+
+	if (data) {
+		/* data should be in a page */
+		data_page = __get_free_page(GFP_KERNEL);
+		if (!data_page)
+			return -ENOMEM;
+		strlcpy((char *) data_page, data, PAGE_SIZE);
+	}
+
+	err = do_mount(name, "/root", fs, flags, (void *) data_page);
+
+	if (data_page)
+		free_page(data_page);
 	if (err)
 		return err;

@@ -417,6 +431,6 @@ void __init prepare_namespace(void)
 	mount_root();
 out:
 	devtmpfs_mount("dev");
-	sys_mount(".", "/", NULL, MS_MOVE, NULL);
+	do_mount(".", "/", NULL, MS_MOVE, NULL);
 	sys_chroot(".");
 }
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 2b10853..8355501 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -48,7 +48,7 @@ static void __init handle_initrd(void)
 	old_fd = sys_open("/old", 0, 0);
 	/* move initrd over / and chdir/chroot in initrd root */
 	sys_chdir("/root");
-	sys_mount(".", "/", NULL, MS_MOVE, NULL);
+	do_mount(".", "/", NULL, MS_MOVE, NULL);
 	sys_chroot(".");

 	/*
@@ -66,7 +66,7 @@ static void __init handle_initrd(void)

 	/* move initrd to rootfs' /old */
 	sys_fchdir(old_fd);
-	sys_mount("/", ".", NULL, MS_MOVE, NULL);
+	do_mount("/", ".", NULL, MS_MOVE, NULL);
 	/* switch root and cwd back to / of rootfs */
 	sys_fchdir(root_fd);
 	sys_chroot(".");
@@ -82,7 +82,7 @@ static void __init handle_initrd(void)
 	mount_root();

 	printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
-	error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
+	error = do_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
 	if (!error)
 		printk("okay\n");
 	else {
--
1.7.0.4


      reply	other threads:[~2010-08-17 14:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-17 12:37 [PATCH] init/do_mounts.c: replace sys_mount() to do_mount() Namhyung Kim
2010-08-17 13:15 ` Arnd Bergmann
2010-08-17 13:25   ` Namhyung Kim
2010-08-17 13:41     ` Arnd Bergmann
2010-08-17 14:38       ` Namhyung Kim [this message]

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=1282055889-6135-1-git-send-email-namhyung@gmail.com \
    --to=namhyung@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox