Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+30 -10
+1
fs/proc/Makefile
··· 9 9 10 10 proc-y += inode.o root.o base.o generic.o array.o \ 11 11 proc_tty.o proc_misc.o 12 + proc-y += cmdline.o 12 13 proc-y += loadavg.o 13 14 proc-y += meminfo.o 14 15 proc-y += uptime.o
+29
fs/proc/cmdline.c
··· 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);
-10
fs/proc/proc_misc.c
··· 472 472 .release = seq_release, 473 473 }; 474 474 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 - 484 475 #ifdef CONFIG_FILE_LOCKING 485 476 static int locks_open(struct inode *inode, struct file *filp) 486 477 { ··· 632 641 char *name; 633 642 int (*read_proc)(char*,char**,off_t,int,int*,void*); 634 643 } *p, simple_ones[] = { 635 - {"cmdline", cmdline_read_proc}, 636 644 {"execdomains", execdomains_read_proc}, 637 645 {NULL,} 638 646 };