From: Al Boldi <a1426z@gawab.com>
To: linux-kernel@vger.kernel.org
Cc: hpa@zytor.com, akpm@linux-foundation.org
Subject: [PATCH][retry-2] init: Introduce rootdir bootparm to select which dir to sys_chroot
Date: Sun, 18 Nov 2007 20:09:19 +0300 [thread overview]
Message-ID: <200711182009.19072.a1426z@gawab.com> (raw)
Second try; this time with a doc-update, and the ability to remount normally.
Tested against 2.6.23.
---
This patch introduces a rootdir kernel boot parameter, which specifies the
path to the kernel sys_chroot boot dir.
This is useful for systems that have more than one distribution installed on
the same fs/partition.
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Al Boldi <a1426z@gawab.com>
---
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1506,6 +1506,10 @@ and is between 256 and 4096 characters.
Useful for devices that are detected asynchronously
(e.g. USB and MMC devices).
+ rootdir= [KNL] Set root dir to chroot to on bootup.
+ Useful for systems that have more than one distribution
+ installed on the same filesystem.
+
rw [KNL] Mount root device read-write on boot
S [KNL] Run init in single mode
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -252,6 +252,16 @@ __setup("rootflags=", root_data_setup);
__setup("rootfstype=", fs_names_setup);
__setup("rootdelay=", root_delay_setup);
+static char __initdata root_dir[128];
+static int __init root_dir_setup(char *str)
+{
+ strcpy(root_dir, "./");
+ strlcat(root_dir, str, sizeof(root_dir));
+ return 1;
+}
+
+__setup("rootdir=", root_dir_setup);
+
static void __init get_fs_names(char *page)
{
char *s = page;
@@ -469,6 +479,12 @@ void __init prepare_namespace(void)
mount_root();
out:
sys_mount(".", "/", NULL, MS_MOVE, NULL);
+
+ if (root_dir) {
+ sys_mount(root_dir, root_dir, NULL, MS_BIND, NULL);
+ sys_chdir(root_dir);
+ }
+
sys_chroot(".");
security_sb_post_mountroot();
}
next reply other threads:[~2007-11-18 17:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-18 17:09 Al Boldi [this message]
2007-11-19 5:22 ` [PATCH][retry-2] init: Introduce rootdir bootparm to select which dir to sys_chroot Arjan van de Ven
2007-11-19 5:56 ` Al Boldi
[not found] <9qVOO-4ZK-13@gated-at.bofh.it>
2007-11-18 19:53 ` Bodo Eggert
2007-11-18 20:02 ` H. Peter Anvin
2007-11-18 23:50 ` Bodo Eggert
2007-11-19 0:02 ` H. Peter Anvin
2007-11-19 5:40 ` Al Boldi
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=200711182009.19072.a1426z@gawab.com \
--to=a1426z@gawab.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
/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