init: Add CONFIG_INITRAMFS_IGNORE_SKIP_FLAG

* Ignoring an ignore flag, yikes
* Also replace skip_initramf with want_initramf (omitting last letter for Magisk since it binary patches that out of kernel, I'm not even sure why we're supporting that mess)

Co-authored-by: Erfan Abdi <erfangplus@gmail.com>
Change-Id: Ifdf726f128bc66bf860bbb71024f94f56879710f
This commit is contained in:
Sebastiano Barezzi 2022-06-28 23:10:29 +02:00 committed by Bruno Martins
parent 912de680b8
commit 9425bb84d4
3 changed files with 43 additions and 1 deletions

View File

@ -2,10 +2,37 @@
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#ifdef CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
#include <asm/setup.h>
#endif
#ifdef CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
#define INITRAMFS_STR_FIND "skip_initramf"
#define INITRAMFS_STR_REPLACE "want_initramf"
#define INITRAMFS_STR_LEN (sizeof(INITRAMFS_STR_FIND) - 1)
static char proc_command_line[COMMAND_LINE_SIZE];
static void proc_command_line_init(void) {
char *offset_addr;
strcpy(proc_command_line, saved_command_line);
offset_addr = strstr(proc_command_line, INITRAMFS_STR_FIND);
if (!offset_addr)
return;
memcpy(offset_addr, INITRAMFS_STR_REPLACE, INITRAMFS_STR_LEN);
}
#endif
static int cmdline_proc_show(struct seq_file *m, void *v)
{
#ifdef CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
seq_printf(m, "%s\n", proc_command_line);
#else
seq_printf(m, "%s\n", saved_command_line);
#endif
return 0;
}
@ -23,6 +50,10 @@ static const struct file_operations cmdline_proc_fops = {
static int __init proc_cmdline_init(void)
{
#ifdef CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
proc_command_line_init();
#endif
proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
return 0;
}

View File

@ -613,7 +613,7 @@ static int __init skip_initramfs_param(char *str)
{
if (*str)
return 0;
do_skip_initramfs = 1;
do_skip_initramfs = !IS_ENABLED(CONFIG_INITRAMFS_IGNORE_SKIP_FLAG);
return 1;
}
__setup("skip_initramfs", skip_initramfs_param);

View File

@ -21,6 +21,17 @@ config INITRAMFS_SOURCE
If you are not sure, leave it blank.
config INITRAMFS_IGNORE_SKIP_FLAG
bool "Force initramfs even when skip_initramfs is set"
default n
help
Ignore skip_initramfs cmdline flag.
This should only be used if you have no control over cmdline
passed by your bootloader yet you can't use CMDLINE_FORCE.
If unsure say N.
config INITRAMFS_ROOT_UID
int "User ID to map to 0 (user root)"
depends on INITRAMFS_SOURCE!=""