From what I understand, on Linux/UNIX files from which you get system info aren't regular files but rather device files and yet I have encountered a file that doesn't seem to be regular (due to its behaviour and size determined by ls and other C functions) but is listed as such (both by ls and when testing with -f in a sh script).
The file is at path /sys/class/thermal/thermal_zone0/temp
on a Raspberry Pi, the result of ls gives that:
-r--r--r-- 1 root root 4096 janv. 18 13:55 /sys/class/thermal/thermal_zone0/temp
There should be a c
or b
if it was a device file.
The issue is that the detected size for this file is 4096 bytes but the real size of the file is actually much smaller.
So I have a few questions: why isn't this file listed as a special file? What C functions should you use to efficiently detect such files and how to measure the size of their content when they are "finite size" files ?
Thank you
/sys
will be of typesysfs
for making visible system information via a filesystem interface. The individual pseudo-files in the pseudo-filesystem are notc
haracter special orb
lock special device files. See for example answers on https://unix.stackexchange.com/questions/236533/sysfs-and-devtmpfs – user4556274 Jan 18 '18 at 15:58