I am new to linux kernel programming. I wrote a simple kernel module and char device. I defined the open(), release(), read() and write() methods of device. I initialize my module with insmod and removed it with rmmod and all works correct. Now I want to check my read() write() methods of the device. Could you please tell me how to write a user program which should implement the read/write methods of my char device ? Thank you.
Share
The first test you can do when you have a character device and you want to check your implementation of
readandwritesyscalls is to:echoshell command:echo 42 > /dev/char_devicecatcommand or a specified number of bytes with theheadcommand (or withdd) and convert to hexadecimal withod -xif necessary:head -8 /dev/char_device | od -xNow to write a program in C, just use
fopento open the file and usefreadandfwriteto read and write data; you can also usereadandwritesyscalls, butfreadandfwriteare standard C library functions that wrapreadandwrite.