I'm looking for a way to dynamically generate the contents of a directory in the /proc filesystem from a kernel module. This is definitely possible since the root /proc directory does it for each running process (and, indeed, that's actually what I want: to have one directory per PID inside of my /proc subdirectory – I'm trying to create a structure like /proc/mymodule/<tgid>/<pid>
). However, the code that does this for the root /proc
directory (found in fs/proc/base.c
) is fairly complicated, and involves keeping an inode cache etc. Furthermore, none of the helper functions used in fs/proc/base.c
are exported, so I'd have to copy & paste them into my module.
Is there any supported interface for dynamically generating the contents of a /proc
directory whenever readdir
is called?