Reputation: 8608
I am trying to open an absolute path of a PCI device in C code
fd = open("/sys/bus/pci/devices/0000:00:01.0/resource", O_RDWR);
if (fd < 0) {
printf("Not found %s\n", path);
return -1;
}
But it gives me an error saying Not found /sys/bus/pci/devices/0000:00:01.0/resource
Can anyone please point me out what I am doing here?
Upvotes: 0
Views: 3203
Reputation: 249642
You are trying to open the path for read/write, but it is only readable (that's what the -r--r--r--
in ls -l
output means). You'll need to change O_RDWR
to O_RDONLY
.
Upvotes: 2