Re: [PATCH] proc: get a reference to the owning module when opening file

From: Boaz Harrosh
Date: Sun Feb 22 2015 - 10:47:10 EST

On 02/21/2015 01:52 PM, Nicolas Iooss wrote:
> I'm basically developing a project where I created an out-of-tree module
> which uses mmap() as a kind of communication channel between a kernel
> module and a userspace program (in short, a ring buffer). The virtual
> file which is used for mmap() was initially created in debugfs, but as
> this filesystem is not always mounted on production systems, I needed
> another one and ended up using procfs. I did not consider creating a
> character or block device in /dev as I wasn't at ease with grabbing a
> major number which could potentially conflict with other out-of-tree
> drivers. As using procfs seems not to be fine, I guess I'll anyway use
> a block device with a major number in the experimental range (240-254).
> In short, the module I'm writing does not have to be in procfs, and I've
> got funnier things to work on than cleaning up vm_operations_struct.

I know that some in-tree drivers do similar things with shmem (tmpfs).
shmem even has an in-kernel API for drivers to create and lock pre-allocated
files, so when user-mode loads they already find what they need.

You should check it out it should have a much better mmap semantics
for you, since it is a real FS.

> Thank you for your detailed reply.
> Nicolas

Good luck

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at