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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 馃悰 handle opening directories with O_DIRECTORY #495

Merged
merged 1 commit into from Jan 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/volume.ts
Expand Up @@ -25,6 +25,7 @@ const {
O_TRUNC,
O_APPEND,
O_SYNC,
O_DIRECTORY,
F_OK,
COPYFILE_EXCL,
COPYFILE_FICLONE_FORCE,
Expand Down Expand Up @@ -912,7 +913,13 @@ export class Volume {
if (!realLink) throw createError(ENOENT, 'open', link.getPath());

const node = realLink.getNode();
if (node.isDirectory() && flagsNum !== FLAGS.r) throw createError(EISDIR, 'open', link.getPath());

// Check whether node is a directory
if (node.isDirectory()) {
if ((flagsNum & (O_RDONLY | O_RDWR | O_WRONLY)) !== O_RDONLY) throw createError(EISDIR, 'open', link.getPath());
} else {
if (flagsNum & O_DIRECTORY) throw createError(ENOTDIR, 'open', link.getPath());
}

// Check node permissions
if (!(flagsNum & O_WRONLY)) {
Expand Down