Is /proc strictly reserved for kernel/driver space

proc

When developing a userspace application or daemon, it is good design practice to provide some form of component status. I have often thought of using /proc for this purpose – is this an acceptable solution? Perhaps there is a userspace library that replicates /proc services?

Most other references that I have found indicate that /proc is reserved for kernel and driver developers.

Best Answer

Indeed, /proc is reserved for kernel space. On Linux, it's a special fs type "procfs", and every file is a handler to some function inside the kernel.

You can't create a folder/file in /proc while being in userland. You may create a kernel module which will talk back to your process, but it won't be a good idea, as you'll have serious security issues. This, without saying the huge risk of memory corruption is something goes wrong.

Anyway, you may take example on the inotify library (userland & kernel) : see the manpage and here's a sample of a kernel module code for creating an entry in /proc : http://linux.die.net/lkmpg/x769.html

Happy hacking :)