Add local data to linux kernel module

Is it possible to create local stream data in a Linux kernel module?

I need to save some data for each process / thread calling my module. Is there an easy way to use local thread data, or do I have to resort to writing a hash map that uses the pid of the current process as a key?

+5
c module linux-kernel thread-local
source share
1 answer

Assuming that the interface for your kernel module is a character device driver, then you have a private_data field in the file structure (which is similar to a user space file descriptor) for that.

Just select and assign a pointer to your selection structure when working with an open file.

This is not exactly a thread or a local process, but in most cases, matching a single file descriptor with your process is true, and it may be enough for you.

+4
source share

All Articles