cmdline.c 651 B

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