In my code NVRAM is implemented as character device and I want to give a condition to check whether it is character device or not. How to implement it programmatically? How can I do it through c++ code.
In terminal I gave command cat /proc/devices and it lists:
Character devices:
1 mem
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/nvram
What does this number 5 in /dev/nvram denote?
The number denotes the device’s major number, and the
Character devices:heading in that listing tells you it’s a character device.If your character device is linked into the filesystem somewhere, like
/dev/mydevice, you can also get information about it via thestatsystem call. Thest_modefield of thestruct statstructure can be tested with theS_ISCHRmacro.