procfs allows arbitrary file_operations, sysfs is more restricted
procfs entries receive a
file_operationsstruct, which contains function pointers that determine what happens to every file-based system call, e.g.open,read,mmap, etc., and you can take arbitrary actions from those.Minimal example:
proc_create()example for kernel module | Stack Overflowsysfs is more restricted in the following senses:
- you implement only two methods
showandstore, which Linux uses to implementopen,close,read,writeandlseekfor you. See also: How to attach file operations to sysfs attribute in platform driver? | Stack Overflow - tightly coupled with
kobject
Minimal example: How to create a simple sysfs class attribute in Linux kernel v3.2 | Stack Overflow
- you implement only two methods