lkml.org 
[lkml]   [2023]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH RFC bootconfig] 1/2] fs/proc: Add /proc/cmdline_load for boot loader arguments
On Fri, Aug 04, 2023 at 10:36:17AM -0700, Paul E. McKenney wrote:
> On Fri, Aug 04, 2023 at 08:23:20PM +0300, Alexey Dobriyan wrote:
> > On Thu, Jul 27, 2023 at 08:37:00PM -0700, Paul E. McKenney wrote:
> > > In kernels built with CONFIG_BOOT_CONFIG_FORCE=y, /proc/cmdline will
> > > show all kernel boot parameters, both those supplied by the boot loader
> > > and those embedded in the kernel image. This works well for those who
> > > just want to see all of the kernel boot parameters, but is not helpful to
> > > those who need to see only those parameters supplied by the boot loader.
> > > This is especially important when these parameters are presented to the
> > > boot loader by automation that might gather them from diverse sources.
> > >
> > > Therefore, provide a /proc/cmdline_load file that shows only those kernel
> > > boot parameters supplied by the boot loader.
> >
> > > +static int cmdline_load_proc_show(struct seq_file *m, void *v)
> > > +{
> > > + seq_puts(m, boot_command_line);
> > > + seq_putc(m, '\n');
> > > + return 0;
> > > +}
> > > +
> > > static int __init proc_cmdline_init(void)
> > > {
> > > struct proc_dir_entry *pde;
> > > @@ -19,6 +27,11 @@ static int __init proc_cmdline_init(void)
> > > pde = proc_create_single("cmdline", 0, NULL, cmdline_proc_show);
> > > pde_make_permanent(pde);
> > > pde->size = saved_command_line_len + 1;
> > > + if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE)) {
> > > + pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show);
> > > + pde_make_permanent(pde);
> > > + pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
> > > + }
> >
> > Please add it as separate fs/proc/cmdline_load.c file so that name of
> > the file matches name of the /proc file.
>
> Thank you, will do!

And here is an untested sneak preview, which I will fold into the original
after testing.

Thoughts?

Thanx, Paul

------------------------------------------------------------------------

diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index bd08616ed8ba..094f3102eb9f 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -34,3 +34,4 @@ proc-$(CONFIG_PROC_VMCORE) += vmcore.o
proc-$(CONFIG_PRINTK) += kmsg.o
proc-$(CONFIG_PROC_PAGE_MONITOR) += page.o
proc-$(CONFIG_BOOT_CONFIG) += bootconfig.o
+proc-$(CONFIG_BOOT_CONFIG_FORCE) += cmdline_load.o
diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
index 1d0ef9d2949d..082def2c1cc6 100644
--- a/fs/proc/cmdline.c
+++ b/fs/proc/cmdline.c
@@ -13,13 +13,6 @@ static int cmdline_proc_show(struct seq_file *m, void *v)
return 0;
}

-static int cmdline_load_proc_show(struct seq_file *m, void *v)
-{
- seq_puts(m, boot_command_line);
- seq_putc(m, '\n');
- return 0;
-}
-
static int __init proc_cmdline_init(void)
{
struct proc_dir_entry *pde;
@@ -27,11 +20,6 @@ static int __init proc_cmdline_init(void)
pde = proc_create_single("cmdline", 0, NULL, cmdline_proc_show);
pde_make_permanent(pde);
pde->size = saved_command_line_len + 1;
- if (IS_ENABLED(CONFIG_BOOT_CONFIG_FORCE)) {
- pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show);
- pde_make_permanent(pde);
- pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
- }
return 0;
}
fs_initcall(proc_cmdline_init);
diff --git a/fs/proc/cmdline_load.c b/fs/proc/cmdline_load.c
new file mode 100644
index 000000000000..e3dccb3441ce
--- /dev/null
+++ b/fs/proc/cmdline_load.c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <asm/setup.h>
+#include "internal.h"
+
+static int cmdline_load_proc_show(struct seq_file *m, void *v)
+{
+ seq_puts(m, boot_command_line);
+ seq_putc(m, '\n');
+ return 0;
+}
+
+static int __init proc_cmdline_load_init(void)
+{
+ struct proc_dir_entry *pde;
+
+ pde = proc_create_single("cmdline_load", 0, NULL, cmdline_load_proc_show);
+ pde_make_permanent(pde);
+ pde->size = strnlen(boot_command_line, COMMAND_LINE_SIZE) + 1;
+ return 0;
+}
+fs_initcall(proc_cmdline_load_init);
\
 
 \ /
  Last update: 2023-08-04 20:44    [W:0.074 / U:1.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site