【问题标题】:Can't open sys/bus/pci/device/ directory无法打开 sys/bus/pci/device/ 目录
【发布时间】:2014-05-14 06:17:53
【问题描述】:

我正在尝试为我的设备读取资源文件,mmap 它是为了读取设备寄存器,但是当我尝试打开文件位置错误提示时:NO such file or directory。我已经使用 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 实用程序读取它。

【问题讨论】:

    标签: c linux pci-bus


    【解决方案1】:

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

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

    而不是绝对的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-06
      • 2017-06-15
      • 2021-05-24
      相关资源
      最近更新 更多