Files
kernel_samsung_sdm670/fs/proc/cmdline.c
Sebastiano Barezzi 60ea96fa56 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
2023-10-24 16:48:02 +00:00

61 lines
1.4 KiB
C

#include <linux/fs.h>
#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;
}
static int cmdline_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, cmdline_proc_show, NULL);
}
static const struct file_operations cmdline_proc_fops = {
.open = cmdline_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
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;
}
fs_initcall(proc_cmdline_init);