Search

Creating read only proc entry in linux 5.3

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.




scripts/link-vmlinux.sh: line 45 : killed make error 137

Compiling custom kernel in debian threw the following error.



There was no point looking for errors in the script file as it is standard script of the kernel source and chances of it being wrong is very remote, so the issue had to be in the system where it was being compiled. A look at the system log using dmesg showed the issue was



As the compilation was being done in a virtual machine, the default value of RAM was set to 1 GB, which was not enough. So increasing the RAM to 4GB and recompiling the kernel was all that was needed.

Inserting an Emoji in gedit

gedit is a popular text editor in linux. Traditionally text editors lacked features like emoticons, but gedit now has the option to add smileys to the text being typed in it.

Open the gedit, right click and Select the insert emoji



Select the emoji that has to be inserted by clicking on the emoticon


The selected emoji will appear with the text.