当前位置: 技术问答>linux和unix
open()打开文件失败,文件存在却返回ENXIO错误?
来源: 互联网 发布时间:2016-07-03
本文导语: 我使用open()函数打开/dev/bcmatm0文件,通过“ls -l”命令,可以查看到该文件的权限为“crwxr--r--”。代码如下: int atm_fd = -1; atm_fd = open("/dev/bcmatm0", O_RDWR); if (-1 == atm_fd) { ...
我使用open()函数打开/dev/bcmatm0文件,通过“ls -l”命令,可以查看到该文件的权限为“crwxr--r--”。代码如下:
int atm_fd = -1;
atm_fd = open("/dev/bcmatm0", O_RDWR);
if (-1 == atm_fd)
{
printf("Error %d: Failed to open filen", errno);
}
运行结果atm_fd为-1,error为ENXIO:No such device or address。于是我使用“strace cat /dev/bcmatm0”查看,同样是ENXIO错误,但是这个文件不是存在的么?
请教各位大侠解答。多谢。
int atm_fd = -1;
atm_fd = open("/dev/bcmatm0", O_RDWR);
if (-1 == atm_fd)
{
printf("Error %d: Failed to open filen", errno);
}
运行结果atm_fd为-1,error为ENXIO:No such device or address。于是我使用“strace cat /dev/bcmatm0”查看,同样是ENXIO错误,但是这个文件不是存在的么?
请教各位大侠解答。多谢。
|
注意看看man page里对ENXIO的解释
ENXIO O_NONBLOCK | O_WRONLY is set, the named file is a FIFO and no process has the file open for reading. Or, the file is a device special file and no corresponding device exists.
ENXIO O_NONBLOCK | O_WRONLY is set, the named file is a FIFO and no process has the file open for reading. Or, the file is a device special file and no corresponding device exists.