Wednesday, December 11, 2013
3:47 PM

Creating directory under /proc in kernel 3.10 and above

In the post Creating a read write proc entry in kernel versions above 3.10 we saw the creation of read write proc entry. In the post we will see how to create folder under /proc and then create a entry under it.

To create a directory under /proc we can make use of the function



Where

name: is the name of the directory to be created. parent: parent is the name of directory under which the new directory has to be created.

To create a directory named "newparent" under /proc we will first declare a string having the name of the new folder





The NULL is passed for parent as we are creating the folder under /proc.

Once the new folder has been created we need to pass the pointer to struct proc_dir_entry to proc_create. The use of proc_create can be seen in the post



The full code for the module along with proc creation will be as shown below. Please refer to the post Creating a read write proc entry in kernel versions above 3.10 for more details

proc_dir.c



The makefile for the same



Compile and load the module using



If there are no errors then we can find the new proc entry under /proc



Thus we can see that under /proc a new folder called newparent has been created in which the proc entry hello has been created. We can read write to this proc entry like other proc entries



Related posts

Creating a read write proc entry in kernel versions above 3.10

Creating read only proc entry in kernel versions above 3.10.

Creating a proc entry - 1

0 comments:

Post a Comment