public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] init: Warn on non-existent rdinit
@ 2012-01-05 18:56 Richard Weinberger
  2012-01-05 20:53 ` Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2012-01-05 18:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: akpm, a.p.zijlstra, mingo, xiyou.wangcong, ebiederm,
	Richard Weinberger

Such a warning would have saved me some time...
Hopefully this printk() saves someone else's time. :-)

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 init/main.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/init/main.c b/init/main.c
index 217ed23..43733c4 100644
--- a/init/main.c
+++ b/init/main.c
@@ -834,6 +834,8 @@ static int __init kernel_init(void * unused)
 		ramdisk_execute_command = "/init";
 
 	if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
+		printk(KERN_WARNING "Warning: unable to access %s!\n",
+					ramdisk_execute_command);
 		ramdisk_execute_command = NULL;
 		prepare_namespace();
 	}
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Warn on non-existent rdinit
  2012-01-05 18:56 [PATCH] init: Warn on non-existent rdinit Richard Weinberger
@ 2012-01-05 20:53 ` Eric W. Biederman
  2012-01-05 21:45   ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2012-01-05 20:53 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: linux-kernel, akpm, a.p.zijlstra, mingo, xiyou.wangcong

Richard Weinberger <richard@nod.at> writes:

> Such a warning would have saved me some time...
> Hopefully this printk() saves someone else's time. :-)

The warning is wrong if you are not using an initramfs or an initial
ramdisk.

I expect what you want is something like:

diff --git a/init/main.c b/init/main.c
index 217ed23..8d53d28 100644
--- a/init/main.c
+++ b/init/main.c
@@ -830,10 +830,11 @@ static int __init kernel_init(void * unused)
         * the work
         */
 
-       if (!ramdisk_execute_command)
+       if (!ramdisk_execute_command &&
+           (sys_access((const char __user *)"/init", 0) == 0))
                ramdisk_execute_command = "/init";
 
-       if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
+       if (!ramdisk_execute_command) {
                ramdisk_execute_command = NULL;
                prepare_namespace();
        }


That way we don't clear ramdisk_execute_command if it was set and
we complain if we attempt exec the ramdisk_execute_command.

Eric

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Warn on non-existent rdinit
  2012-01-05 20:53 ` Eric W. Biederman
@ 2012-01-05 21:45   ` Richard Weinberger
  2012-01-05 22:00     ` Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2012-01-05 21:45 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: linux-kernel, akpm, a.p.zijlstra, mingo, xiyou.wangcong

[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]

Am 05.01.2012 21:53, schrieb Eric W. Biederman:
> Richard Weinberger <richard@nod.at> writes:
> 
>> Such a warning would have saved me some time...
>> Hopefully this printk() saves someone else's time. :-)
> 
> The warning is wrong if you are not using an initramfs or an initial
> ramdisk.

Gnah, you're so right.
I did not test it without a ramdisk.

> I expect what you want is something like:
> 
> diff --git a/init/main.c b/init/main.c
> index 217ed23..8d53d28 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -830,10 +830,11 @@ static int __init kernel_init(void * unused)
>          * the work
>          */
>  
> -       if (!ramdisk_execute_command)
> +       if (!ramdisk_execute_command &&
> +           (sys_access((const char __user *)"/init", 0) == 0))
>                 ramdisk_execute_command = "/init";
>  
> -       if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
> +       if (!ramdisk_execute_command) {
>                 ramdisk_execute_command = NULL;
>                 prepare_namespace();
>         }

Why ramdisk_execute_command = NULL; in the !ramdisk_execute_command case?

> 
> That way we don't clear ramdisk_execute_command if it was set and
> we complain if we attempt exec the ramdisk_execute_command.

If "/init" does not exist we still don't get a warning.

Thanks,
//richard



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Warn on non-existent rdinit
  2012-01-05 21:45   ` Richard Weinberger
@ 2012-01-05 22:00     ` Eric W. Biederman
  2012-01-05 22:03       ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2012-01-05 22:00 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: linux-kernel, akpm, a.p.zijlstra, mingo, xiyou.wangcong

Richard Weinberger <richard@nod.at> writes:

> Am 05.01.2012 21:53, schrieb Eric W. Biederman:
>> Richard Weinberger <richard@nod.at> writes:
>> 
>>> Such a warning would have saved me some time...
>>> Hopefully this printk() saves someone else's time. :-)
>> 
>> The warning is wrong if you are not using an initramfs or an initial
>> ramdisk.
>
> Gnah, you're so right.
> I did not test it without a ramdisk.
>
>> I expect what you want is something like:
>> 
>> diff --git a/init/main.c b/init/main.c
>> index 217ed23..8d53d28 100644
>> --- a/init/main.c
>> +++ b/init/main.c
>> @@ -830,10 +830,11 @@ static int __init kernel_init(void * unused)
>>          * the work
>>          */
>>  
>> -       if (!ramdisk_execute_command)
>> +       if (!ramdisk_execute_command &&
>> +           (sys_access((const char __user *)"/init", 0) == 0))
>>                 ramdisk_execute_command = "/init";
>>  
>> -       if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
>> +       if (!ramdisk_execute_command) {
>>                 ramdisk_execute_command = NULL;
>>                 prepare_namespace();
>>         }
>
> Why ramdisk_execute_command = NULL; in the !ramdisk_execute_command
> case?

Because in my untested patch I didn't get as far as deleting that line.

>> That way we don't clear ramdisk_execute_command if it was set and
>> we complain if we attempt exec the ramdisk_execute_command.
>
> If "/init" does not exist we still don't get a warning.

Perhaps it has a /linuxrc.  If you can find a way of figuring out we
always need the file we can print an error.  Otherwise it is a case of
the kernel auto-detecting what to do, and not printing a warning when it
has decided there is no /init to play with.

Eric

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] init: Warn on non-existent rdinit
  2012-01-05 22:00     ` Eric W. Biederman
@ 2012-01-05 22:03       ` Richard Weinberger
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2012-01-05 22:03 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: linux-kernel, akpm, a.p.zijlstra, mingo, xiyou.wangcong

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

Am 05.01.2012 23:00, schrieb Eric W. Biederman:
> Perhaps it has a /linuxrc.  If you can find a way of figuring out we
> always need the file we can print an error.  Otherwise it is a case of
> the kernel auto-detecting what to do, and not printing a warning when it
> has decided there is no /init to play with.
> 

If i find a nice way, I'll post a patch.

In my case I had a kernel with a built-in initramfs which contained a /linuxrc, but no /init.
I had no clue why the kernel always tried to boot from root=.

Thanks,
//richard



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-05 22:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05 18:56 [PATCH] init: Warn on non-existent rdinit Richard Weinberger
2012-01-05 20:53 ` Eric W. Biederman
2012-01-05 21:45   ` Richard Weinberger
2012-01-05 22:00     ` Eric W. Biederman
2012-01-05 22:03       ` Richard Weinberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox