procfs
file: /proc/bus/pci/00/00.0
vs.
sysfs
file: /sys/bus/pci/devices/0000:00:00.0/resource
I have seen some drivers use the procfs
file and some use sysfs
. What is the difference? For what I need, I find that mmap
-ing the sysfs/resource<n>?
file and read/write works as I need it to, but similar operation on the procfs
file does not work. But obviously the procfs
file is used successfully elsewhere.
The procfs
file you cite (/proc/bus/pci/00/00.0
) provides access to the device's configuration header. It is also accessible in sysfs
as /sys/bus/pci/devices/0000:00:00.0/config
.
The sysfs
file you're talking about (/sys/bus/pci/devices/0000:00:00.0/resource<N>
) provides access to the device's BAR regions. See https://en.wikipedia.org/wiki/PCI_configuration_space for an explanation of the relationships. Also, you may want to read the linux kernel documentation at
https://www.kernel.org/doc/Documentation/filesystems/sysfs-pci.txt