Skip to content

Commit cf9887f

Browse files
author
Alexey Dobriyan
committed
proc: switch /proc/cmdline to seq_file
and move it to fs/proc/cmdline.c while I'm at it. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
1 parent 6827400 commit cf9887f

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

‎fs/proc/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ proc-$(CONFIG_MMU) := mmu.o task_mmu.o
99

1010
proc-y += inode.o root.o base.o generic.o array.o \
1111
proc_tty.o proc_misc.o
12+
proc-y += cmdline.o
1213
proc-y += loadavg.o
1314
proc-y += meminfo.o
1415
proc-y += uptime.o

‎fs/proc/cmdline.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <linux/fs.h>
2+
#include <linux/init.h>
3+
#include <linux/proc_fs.h>
4+
#include <linux/seq_file.h>
5+
6+
static int cmdline_proc_show(struct seq_file *m, void *v)
7+
{
8+
seq_printf(m, "%s\n", saved_command_line);
9+
return 0;
10+
}
11+
12+
static int cmdline_proc_open(struct inode *inode, struct file *file)
13+
{
14+
return single_open(file, cmdline_proc_show, NULL);
15+
}
16+
17+
static const struct file_operations cmdline_proc_fops = {
18+
.open = cmdline_proc_open,
19+
.read = seq_read,
20+
.llseek = seq_lseek,
21+
.release = single_release,
22+
};
23+
24+
static int __init proc_cmdline_init(void)
25+
{
26+
proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
27+
return 0;
28+
}
29+
module_init(proc_cmdline_init);

‎fs/proc/proc_misc.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,6 @@ static const struct file_operations proc_interrupts_operations = {
472472
.release = seq_release,
473473
};
474474

475-
static int cmdline_read_proc(char *page, char **start, off_t off,
476-
int count, int *eof, void *data)
477-
{
478-
int len;
479-
480-
len = sprintf(page, "%s\n", saved_command_line);
481-
return proc_calc_metrics(page, start, off, count, eof, len);
482-
}
483-
484475
#ifdef CONFIG_FILE_LOCKING
485476
static int locks_open(struct inode *inode, struct file *filp)
486477
{
@@ -641,7 +632,6 @@ void __init proc_misc_init(void)
641632
char *name;
642633
int (*read_proc)(char*,char**,off_t,int,int*,void*);
643634
} *p, simple_ones[] = {
644-
{"cmdline", cmdline_read_proc},
645635
{"execdomains", execdomains_read_proc},
646636
{NULL,}
647637
};

0 commit comments

Comments
 (0)