Skip to content

Commit

Permalink
init: Add CONFIG_INITRAMFS_IGNORE_SKIP_FLAG
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Change-Id: Ifdf726f128bc66bf860bbb71024f94f56879710f
  • Loading branch information
2 people authored and luk1337 committed Oct 25, 2023
1 parent 795f41c commit 17c6484
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
31 changes: 31 additions & 0 deletions fs/proc/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion init/initramfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions usr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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!=""
Expand Down

0 comments on commit 17c6484

Please sign in to comment.