In the post "Creating proc read and write entry (linux kernel 4.6)" we saw the details of creating a proc entry in linux kernel version 4.6 .The following is the code to create a simple proc entry which can only be read from which works in the linux kernel 5.3.
The only change in this as compared to the previous post for version 4.6 is the use of function "simple_read_from_buffer" which copies data from buffer, which is memory in the kernel space to user space. It returns the size of the data of bytes of data to read. The return type of function written to read the proc content is changed to ssize_t from int. Thus making the above two changes the read_proc function now looks like this
Thus the full code for creating the proc entry is
The make file required to compile the above code is
Compile and test the module using the following steps.
The only change in this as compared to the previous post for version 4.6 is the use of function "simple_read_from_buffer" which copies data from buffer, which is memory in the kernel space to user space. It returns the size of the data of bytes of data to read. The return type of function written to read the proc content is changed to ssize_t from int. Thus making the above two changes the read_proc function now looks like this
Thus the full code for creating the proc entry is
The make file required to compile the above code is
Compile and test the module using the following steps.