无法打开 /sys/bus/pci/devices/0000:00:01.0/资源
Unable to open /sys/bus/pci/devices/0000:00:01.0/resource
我正在尝试用 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
谁能指出我在这里做什么?
您正在尝试打开 read/write 的路径,但它只是可读的(这就是 ls -l
输出中的 -r--r--r--
的意思)。您需要将 O_RDWR
更改为 O_RDONLY
。
我正在尝试用 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
谁能指出我在这里做什么?
您正在尝试打开 read/write 的路径,但它只是可读的(这就是 ls -l
输出中的 -r--r--r--
的意思)。您需要将 O_RDWR
更改为 O_RDONLY
。