* [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
@ 2007-11-06 10:40 Al Boldi
2007-11-07 20:10 ` Al Boldi
2007-11-09 4:36 ` Andrew Morton
0 siblings, 2 replies; 7+ messages in thread
From: Al Boldi @ 2007-11-06 10:40 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa, akpm
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/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -252,6 +252,15 @@ __setup("rootflags=", root_data_setup);
__setup("rootfstype=", fs_names_setup);
__setup("rootdelay=", root_delay_setup);
+static char * __initdata root_dir;
+static int __init root_dir_setup(char *str)
+{
+ root_dir = strcat("./",str);
+ return 1;
+}
+
+__setup("rootdir=", root_dir_setup);
+
static void __init get_fs_names(char *page)
{
char *s = page;
@@ -469,6 +478,10 @@ void __init prepare_namespace(void)
mount_root();
out:
sys_mount(".", "/", NULL, MS_MOVE, NULL);
+
+ if(root_dir)
+ sys_chdir(root_dir);
+
sys_chroot(".");
security_sb_post_mountroot();
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
2007-11-07 20:10 ` Al Boldi
@ 2007-11-06 20:13 ` H. Peter Anvin
2007-11-07 21:13 ` Al Boldi
0 siblings, 1 reply; 7+ messages in thread
From: H. Peter Anvin @ 2007-11-06 20:13 UTC (permalink / raw)
To: Al Boldi; +Cc: linux-kernel, akpm
Al Boldi wrote:
> Al Boldi wrote:
>> 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.
This seems like something that should be done via an initramfs.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
2007-11-07 21:13 ` Al Boldi
@ 2007-11-06 21:25 ` H. Peter Anvin
0 siblings, 0 replies; 7+ messages in thread
From: H. Peter Anvin @ 2007-11-06 21:25 UTC (permalink / raw)
To: Al Boldi; +Cc: linux-kernel, akpm
Al Boldi wrote:
> H. Peter Anvin wrote:
>> Al Boldi wrote:
>>> Al Boldi wrote:
>>>> 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.
>> This seems like something that should be done via an initramfs.
>
> Agreed. But, not everybody boots their systems via initramfs, and even if
> they did, they also have to know how to reconfigure it.
>
> In contrast, this patch offers the rootdir functionality as a simple bootparm
> and without any extra initramfs dependency.
>
And yet another hack in the kernel!
Instead of heaping hack du jour into the kernel, write a small initramfs
that provides the appropriate functionality, please.
-hpa
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
2007-11-06 10:40 [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot Al Boldi
@ 2007-11-07 20:10 ` Al Boldi
2007-11-06 20:13 ` H. Peter Anvin
2007-11-09 4:36 ` Andrew Morton
1 sibling, 1 reply; 7+ messages in thread
From: Al Boldi @ 2007-11-07 20:10 UTC (permalink / raw)
To: linux-kernel; +Cc: hpa, akpm
Al Boldi wrote:
> 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/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -252,6 +252,15 @@ __setup("rootflags=", root_data_setup);
> __setup("rootfstype=", fs_names_setup);
> __setup("rootdelay=", root_delay_setup);
>
> +static char * __initdata root_dir;
> +static int __init root_dir_setup(char *str)
> +{
> + root_dir = strcat("./",str);
This line is probably using an overloaded function that does not exist.
Use this instead:
static char __initdata root_dir[128];
static int __init root_dir_setup(char *str)
{
strcpy(root_dir, "./");
strlcat(root_dir, str, sizeof(root_dir) - strlen(root_dir) - 1);
return 1;
}
> +__setup("rootdir=", root_dir_setup);
> +
> static void __init get_fs_names(char *page)
> {
> char *s = page;
> @@ -469,6 +478,10 @@ void __init prepare_namespace(void)
> mount_root();
> out:
> sys_mount(".", "/", NULL, MS_MOVE, NULL);
> +
> + if(root_dir)
> + sys_chdir(root_dir);
> +
> sys_chroot(".");
> security_sb_post_mountroot();
> }
Thanks!
--
Al
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
2007-11-06 20:13 ` H. Peter Anvin
@ 2007-11-07 21:13 ` Al Boldi
2007-11-06 21:25 ` H. Peter Anvin
0 siblings, 1 reply; 7+ messages in thread
From: Al Boldi @ 2007-11-07 21:13 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: linux-kernel, akpm
H. Peter Anvin wrote:
> Al Boldi wrote:
> > Al Boldi wrote:
> >> 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.
>
> This seems like something that should be done via an initramfs.
Agreed. But, not everybody boots their systems via initramfs, and even if
they did, they also have to know how to reconfigure it.
In contrast, this patch offers the rootdir functionality as a simple bootparm
and without any extra initramfs dependency.
Thanks!
--
Al
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
2007-11-06 10:40 [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot Al Boldi
2007-11-07 20:10 ` Al Boldi
@ 2007-11-09 4:36 ` Andrew Morton
2007-11-09 4:57 ` Al Boldi
1 sibling, 1 reply; 7+ messages in thread
From: Andrew Morton @ 2007-11-09 4:36 UTC (permalink / raw)
To: Al Boldi; +Cc: linux-kernel, hpa
> On Tue, 6 Nov 2007 13:40:26 +0300 Al Boldi <a1426z@gawab.com> wrote:
>
> 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/init/do_mounts.c
> +++ b/init/do_mounts.c
> @@ -252,6 +252,15 @@ __setup("rootflags=", root_data_setup);
> __setup("rootfstype=", fs_names_setup);
> __setup("rootdelay=", root_delay_setup);
>
> +static char * __initdata root_dir;
> +static int __init root_dir_setup(char *str)
> +{
> + root_dir = strcat("./",str);
> + return 1;
> +}
> +
> +__setup("rootdir=", root_dir_setup);
Please update Documentation/kernel-parameters.txt when adding __setup
options.
> static void __init get_fs_names(char *page)
> {
> char *s = page;
> @@ -469,6 +478,10 @@ void __init prepare_namespace(void)
> mount_root();
> out:
> sys_mount(".", "/", NULL, MS_MOVE, NULL);
> +
> + if(root_dir)
> + sys_chdir(root_dir);
> +
Please run scripts/checkpatch.pl across all patches before sending them to
anyone.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot
2007-11-09 4:36 ` Andrew Morton
@ 2007-11-09 4:57 ` Al Boldi
0 siblings, 0 replies; 7+ messages in thread
From: Al Boldi @ 2007-11-09 4:57 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel, hpa
Andrew Morton wrote:
> > On Tue, 6 Nov 2007 13:40:26 +0300 Al Boldi <a1426z@gawab.com> wrote:
> >
> > 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/init/do_mounts.c
> > +++ b/init/do_mounts.c
> > @@ -252,6 +252,15 @@ __setup("rootflags=", root_data_setup);
> > __setup("rootfstype=", fs_names_setup);
> > __setup("rootdelay=", root_delay_setup);
> >
> > +static char * __initdata root_dir;
> > +static int __init root_dir_setup(char *str)
> > +{
> > + root_dir = strcat("./",str);
> > + return 1;
> > +}
> > +
> > +__setup("rootdir=", root_dir_setup);
>
> Please update Documentation/kernel-parameters.txt when adding __setup
> options.
Sure.
If you think this feature is useful, which I think it is, then I probably
need to resend with a doc update. But bare in mind, this patch needs
something like small hack to allow remounting root, which currently isn't
possible. I'm sure hpa is probably the genius to help out here.
>
> > static void __init get_fs_names(char *page)
> > {
> > char *s = page;
> > @@ -469,6 +478,10 @@ void __init prepare_namespace(void)
> > mount_root();
> > out:
> > sys_mount(".", "/", NULL, MS_MOVE, NULL);
> > +
> > + if(root_dir)
> > + sys_chdir(root_dir);
> > +
>
> Please run scripts/checkpatch.pl across all patches before sending them to
> anyone.
Ok.
Thanks!
--
Al
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2007-11-09 4:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-06 10:40 [PATCH] init: Introduce rootdir bootparm to select which dir to sys_chroot Al Boldi
2007-11-07 20:10 ` Al Boldi
2007-11-06 20:13 ` H. Peter Anvin
2007-11-07 21:13 ` Al Boldi
2007-11-06 21:25 ` H. Peter Anvin
2007-11-09 4:36 ` Andrew Morton
2007-11-09 4:57 ` Al Boldi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox