-2

I've recently learned about kernel modules and I was thinking on how to create one that does what cat /proc/cpuinfo does.

Is it possible to do this without opening/reading the file directly (fread)?

Thanks in advance!

Rarblack
  • 4,559
  • 4
  • 22
  • 33
  • Could you try to prepare some example(s) and ask more specific question please? – rudolf_franek Oct 10 '18 at 13:42
  • Possible [duplicate question](https://stackoverflow.com/questions/9629850/how-to-get-cpu-info-in-c-on-linux-such-as-number-of-cores). But can't you get the cpu info directly from the processor itself? – Weather Vane Oct 10 '18 at 13:52

1 Answers1

0

/proc/cpuinfo output is generated by kernel code; you can check that code and do the same in your kernel module.

Code is located in fs/proc/cpuinfo.c

It references 'cpuinfo_op' object that is provided by architecture-dependent code, try 'grep cpuinfo_op arch' from toplevel directory of kernel source to locate it.