1

我正在尝试读取设备的资源文件并mmap读取设备寄存器,但是当我尝试打开文件位置错误提示时:没有这样的文件或目录。我已经使用 chmod 666 更改了文件的权限。我用来打开文件的代码:

sprintf(filePath , "sys/bus/pci/devices/%04x:%02x:%02x.%d/resource0",segment,bus,device,function)

fileHandle = open(filePath , O_RDONLY);

if (fileHandle < 0)
{
    perror("ERRRO : ");
}

该文件存在,我可以使用 cat 实用程序读取它。

4

1 回答 1

3

您正在尝试打开相对路径(不存在):

sys/bus/pci/devices/%04x:%02x:%02x.%d/resource0

而不是一个绝对的:

/sys/bus/pci/devices/%04x:%02x:%02x.%d/resource0
于 2014-05-14T06:19:54.233 回答