init: Add CONFIG_INITRAMFS_IGNORE_SKIP_FLAG

* Ignoring an ignore flag, yikes
* Also replace skip_initramfs with want_initramfs

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 Pranav Vashi
parent af81150d1e
commit 127198fdd5
3 changed files with 43 additions and 1 deletions

View File

@@ -3,10 +3,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_initramfs"
#define INITRAMFS_STR_REPLACE "want_initramfs"
#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;
}
@@ -24,6 +51,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

@@ -614,7 +614,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

@@ -32,6 +32,17 @@ config INITRAMFS_FORCE
and is useful if you cannot or don't want to change the image
your bootloader passes to the kernel.
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!=""