The Linux kernel exposes information about the current environment using the sysfs filesystem in /sys. I'm interested in getting information about online CPUs and their memory hierarchy (Level 1 to Level 3 caches).
Since all this information is basically text files I could write a parser on my own, but I'm curious what the best way of processing the information in sysfs is. Currently I found two alternatives:
libsysfs
and
libudev
The downside of libsysfs
seems to be that the code is now almost 5 years old and almost no documentation is available, libudev
seems more active but documentation is quite rare. There was only one useful tutorial I found on libudev
-- http://www.signal11.us/oss/udev/
What is the state of the art way to process content from sysfs in C/C++?
[Update]
Currently it is not possible to access data stored in /sys/devices/system
due to the fact that the exposed information are not real devices. The only way to access this data is to do it manually.
The kernel authors have published sysfs-rules.txt, which explains how sysfs must be used. They point out in particular
Do not use libsysfs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With