Linux的公开征集的可能原因返回EINVAL [英] Possible reasons of linux open call returning EINVAL

查看:162
本文介绍了Linux的公开征集的可能原因返回EINVAL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的源$ C ​​$ C系统调用如下:

I am trying to make a system call in my source code as follows.

int file;
file = open(argv[index], O_RDONLY);

当命令行实际参数的是在我的文件系统中的二进制文件的路径。但这个电话引发了我一个 EINVAL 错误。我已经检查文件是否存在以及所需的权限来访问它。

Where the command line arguement is a path to a binary file in my filesystem. But this call throws me an EINVAL error. I have checked the existence of file and the required permissions to access it.

在什么情况下 EINVAL 错误将被抛出。任何建议

Any suggestions on what circumstances the EINVAL error will be thrown out.

推荐答案

失败原因:

有两个说的过程(过程1和过程2)是在接近的续集执行,并试图打开这个二进制文件。因为我的系统(嵌入式设备)将在公开征集之后崩溃,分裂出来的(1)调试不正确的,它让我怀疑的过程-1。但实际的罪魁祸首是过程-2谁是打开与 O_RDWR 标记的二进制文件。但我的文件系统(网络安装)是安装为只读文件系统

There were two processes say (process-1 and process-2) that were executing in close sequel and was trying to open this binary file. Since my system (embedded device) will crash after this open call, the debugs splitted out weren't proper and it made me to suspect the process-1. But the actual culprit is process-2 who was opening the binary with O_RDWR flag. But my file system (network mount) was mounted as "read only file system".

点被照顾:

细化的 PERROR 打印应该是问题的正确原因为只读文件系统。所以,我最初的 PERROR 说明必须是任何previous错误调用的未清除的值。这里是一个学习是使用 PERROR 小心,从而避免误导性分析的错误消息。

Refining the perror prints it should be the right cause of the problem as "Read Only File System". So my initial perror description must be a uncleared value of any of the previous erroneous call. One learning here is to use perror with care, so as avoid analysing misleading error message.

可能的情况下, EINVAL 错误会抛出

Possible circumstances the EINVAL error will be thrown out:

公开招募将显示一个 EINVAL 如果我们使用O_SYNC相关(OR)为标志,我们不应该使用的文件。我断定这个基于文档由雷夫pviously提到的$ P $上。

The open call will show an EINVAL if we use O_SYNC (or) related flags for the file which we are not supposed to use. I conclude this based on the documentation as previously mentioned by Rafe.

这篇关于Linux的公开征集的可能原因返回EINVAL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆