Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O_DIRECTORY does not fail on open() #143

Open
luxe opened this issue Feb 18, 2020 · 0 comments
Open

O_DIRECTORY does not fail on open() #143

luxe opened this issue Feb 18, 2020 · 0 comments

Comments

@luxe
Copy link

luxe commented Feb 18, 2020

Problem:

I'm trying to use O_DIRECTORY with open(2).
It says, if pathname is not a directory, cause the open to fail.
jnr-posix does not seem to fail when opening a file with O_DIRECTORY.

Example:

mkdir dir_example;
touch file_example;

POSIX posix = POSIXFactory.getNativePOSIX();
int fd1 = posix.open("dir_example", OpenFlags.O_DIRECTORY.intValue(), 0444);
System.out.println(fd1);
int fd2 = posix.open(" file_example", OpenFlags.O_DIRECTORY.intValue(), 0444);
System.out.println(fd2);

Both fd1 and fd2 are non-negative integers. I would expect fd2 to be a negative indicating that the open failed. I see the correct behavior when using c directly.

I have also tried using:

POSIX posix = POSIXFactory.getPOSIX(new DefaultPOSIXHandler(), true);

Is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant