cpuinfo.c 564 B

123456789101112131415161718192021222324
  1. #include <linux/fs.h>
  2. #include <linux/init.h>
  3. #include <linux/proc_fs.h>
  4. #include <linux/seq_file.h>
  5. extern const struct seq_operations cpuinfo_op;
  6. static int cpuinfo_open(struct inode *inode, struct file *file)
  7. {
  8. return seq_open(file, &cpuinfo_op);
  9. }
  10. static const struct file_operations proc_cpuinfo_operations = {
  11. .open = cpuinfo_open,
  12. .read = seq_read,
  13. .llseek = seq_lseek,
  14. .release = seq_release,
  15. };
  16. static int __init proc_cpuinfo_init(void)
  17. {
  18. proc_create("cpuinfo", 0, NULL, &proc_cpuinfo_operations);
  19. return 0;
  20. }
  21. fs_initcall(proc_cpuinfo_init);