* Ignoring an ignore flag, yikes * Also replace skip_initramfs with want_initramfs Co-authored-by: Erfan Abdi <erfangplus@gmail.com> Change-Id: Ifdf726f128bc66bf860bbb71024f94f56879710f
62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#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_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;
|
|
}
|
|
|
|
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);
|