Re: [PATCH] init: Warn on non-existent rdinit

Richard Weinberger
2012-01-05T21:45:34Z

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