Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    Cool, :) this is the first thing I tried as I saw the question: strace -o catcpuproc.txt cat /proc/cpuinfo Commented Mar 27, 2014 at 3:18
  • 2
    Nice answer! On linux, if you want to dig deeper, the source for the proc filesystem is in fs/proc in the kernel source. You'll see that there is a fs/proc/cpuinfo.c but, unfortunately, it is rather empty since the heavy lifting is spread out all over arch/ as it is architecture dependent. For a simpler example see fs/proc/uptime.c. By glancing at the file we can guess that uptime_proc_show is the workhorse of what gets us the data we want and we could explore it more by diving into the functions it calls. To understand the seq_file interface and how it is used in procfs see: Commented Mar 27, 2014 at 4:08
  • 1
    linux.com/learn/linux-training/… and lwn.net/Articles/22355 (a bit dated) Commented Mar 27, 2014 at 4:09
  • 2
    @slm : +1, great answer. But to me, the first hint it's a special file is its size ^^ 0 bytes, yet you can cat lots of things from it (a bit like some pipe files). Commented Mar 27, 2014 at 9:16
  • @OlivierDulac - good point. I've made additional edits based on your feedback. LMK if I can make any further improvements. Thanks. Commented Mar 27, 2014 at 11:49