Let's code a Linux Driver - 18: Create procfs entries from a Linux Kernel Module

preview_player
Показать описание
#FOSS #Linux #GNU #KernelModules #LinuxDriver #Tutorial

Let's leave userspace and head towards Kernelspace!

In this series of videos I will show you how to write your own Linux Driver. We have already used device files, but there is an easier way - files in procfs! In this video I will show you how to add a folder and a file in the Process Filesystem /proc.

Here is the link to my git-repo:

You want to learn more? Check out my playlist:

Resource for this video:
Рекомендации по теме
Комментарии
Автор

In the read/write callbacks, shouldn't `if(offs) *offs += delta;` be added?

fghoussen
Автор

In case if someone is using kernel < 5, then use static struct file_operations fops = { .read and .write }

JS-vbbi
Автор

New to LKMs: these videos are really great! Thanks for providing this.
Looks like you can already read/write information sent from/to user/kernel space from `/dev/dummy` device files (previous videos). ioctl look similar too: they enable to interact (passing information) to/from the LKM. I understand the same kind of things can be done with `/proc/dummy` procfs files.

What is the logic behind? In practice, what kind of information should be passed by device files or procfs files? Are there some rules? Or are they just as many different ways to do the same thing?

fghoussen
Автор

hello jhoannes it would be really interesting if I wrote a kernel module starting from device tree!

simonedallai
Автор

When trying to test this I get `head: /proc/hello/dummy: cannot seek to relative offset -490: Illegal seek` ... And then only the expected message. Adding `if(offs) *offs += delta;` doesn't help. Any clue is welcome

fghoussen
Автор

I run the procfs program it will read data at infinity time why?

punniyaseelanh
Автор

a bit annoying that you already had half of the code written and never explained it (my_read, my_write etc.) - do you cover that in another video or something?

cjones
visit shbcf.ru