EINVAL error in open()

Hi all,

I have observed an error in open() system call to open a hard-drive partition.
The error number is EINVAL. The application is not returning this error always.
But on some occasions. QNX help says EINVAL - The requested synchronized modes (O_SYNC, O_DSYNC, O_RSYNC) aren’t supported.
This is my open() statement:-
desc = open("/dev/hd0txx", O_RDWR);
Could you please share any other possibilities of causing this error?


Could the problem be related to who is running the code? I have a feeling that you need to be super user to do this open.

Thanks for the reply.
No. It is not related to the user. I have checked this application with root login always.
Also the application works fine for many cases (various other user inputs).
I doubt there is some code-wise error in my application. But I couldn’t detect any yet.
So could you please give some pointers on what cases EINVAL can occur for a drive open?
I am using the same flags in open() for all the user input cases (which it worked).
Also for the same input it didn’t work, it worked fine for first two attempts. On the third
attempt, it fails.


Well in general EINVAL refers to an Invalid Parameter. Your call only has two parameters.

“/dev/hd0txx” and O_RDWR

Let’s assume that you are not putting in “/dev/hd0txx” literally. If you listed a drive that was not there, I think the error would be different. So that leaves O_RDWR. The only reason I can think of that this would cause EINVAL would be that you don’t have permission, which you say is not the case, or if the drive were somehow Read-Only. That might occur if the drive were already open, but I’m not sure. That’s all I can think of.

Post the exact code you are using.