When to use / proc and when / dev

I need to write a kernel module that is not a device driver. This module will interact with some user space processes. Since I do not want to use ioctl (), I can either create a file in the / proc directory or create a device file in the / dev directory.

Question: How do I decide between / proc and / dev. Is it just a call to court or is there some unwritten agreement on the use of these two.

+5
source share
1 answer

You will have many difficulties adding a new interface to / proc /. Kernel developers are unhappy that it has become a dump for different interfaces, and if you do not actually modify any processes through / proc / pid /, I think it will be difficult for you to convince the kernel community to accept it.

The device file in / dev / may be acceptable even for modules that are not actually device drivers. (e.g. / dev / kvm, / dev / pts, / dev / ecryptfs, / dev / fuse, / dev / kmsg, / dev / ptmx, etc.) However, device files are processed too often with ioctl (), and I think you are right to avoid this if you can.

sysfs . sysfs , . , . , , fs/libfs.c . ( , configfs, , . , ?)

+6

All Articles