You can see the data being assembled on the fly from data in various variables in the kernel, including a few numbers computed on the fly such as the CPU frequency.Ī big part of /proc is the per-process information in /proc/. There the main function is show_cpuinfo, which prints out the desired file content the rest of the infrastructure is there to feed the data to the reading process at the speed it requests it. Taking x86 as an example, we're led to arch/x86/kernel/cpu/proc.c. There is merely a seq_operations structure, and the real meat is in the cpuinfo_op data structure, which is architecture-dependent, usually defined in arch//kernel/setup.c (or sometimes a different file). You can see that the code is pretty much boilerplate code: since most files under /proc just dump some text data, there are helper functions to do that. Taking /proc/cpuinfo as an example, a search for "cpuinfo" leads you to the call to proc_create("cpuinfo, …") in fs/proc/cpuinfo.c. Kernel versions up to 3.9 provide the functions create_proc_entry and some wrappers (especially create_proc_read_entry), and kernel versions 3.10 and above provide instead only proc_create and proc_create_data (and a few more). Drivers call functions declared in include/linux/proc_fs.h. Any driver can register entries in /proc (though as indicated above this is now deprecated in favor of /sys), so if you don't find what you're looking for in fs/proc, look everywhere else. The core handling of /proc entries is in the fs/proc directory. (There are many variants of LXR the one running on is the nicest by far but unfortunately the site is often down.) A little knowledge of C is required, but you don't need to be a programmer to track down a mysterious value. You can download the source on your machine, but this is a huge program, and LXR, the Linux cross-reference, is a big help. Your third entry point, when the documentation doesn't cover it, is reading the source.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |