version.c 761 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <linux/fs.h>
  2. #include <linux/init.h>
  3. #include <linux/kernel.h>
  4. #include <linux/proc_fs.h>
  5. #include <linux/seq_file.h>
  6. #include <linux/utsname.h>
  7. static int version_proc_show(struct seq_file *m, void *v)
  8. {
  9. seq_printf(m, linux_proc_banner,
  10. utsname()->sysname,
  11. utsname()->release,
  12. utsname()->version);
  13. return 0;
  14. }
  15. static int version_proc_open(struct inode *inode, struct file *file)
  16. {
  17. return single_open(file, version_proc_show, NULL);
  18. }
  19. static const struct file_operations version_proc_fops = {
  20. .open = version_proc_open,
  21. .read = seq_read,
  22. .llseek = seq_lseek,
  23. .release = single_release,
  24. };
  25. static int __init proc_version_init(void)
  26. {
  27. proc_create("version", 0, NULL, &version_proc_fops);
  28. return 0;
  29. }
  30. fs_initcall(proc_version_init);