我试图在C代码中打开PCI设备的绝对路径
fd = open("/sys/bus/pci/devices/0000:00:01.0/resource", O_RDWR);
if (fd < 0) {
printf("Not found %s\n", path);
return -1;
}
但是它给我一个错误,说找不到/sys/bus/pci/devices/0000:00:01.0/resource
有人可以指出我在这里做什么吗?
答案 0 :(得分:2)
您正在尝试打开读/写路径,但它只是可读的(-r--r--r--
输出中的ls -l
意味着什么)。您需要将O_RDWR
更改为O_RDONLY
。