Skip to content
Snippets Groups Projects
Commit 05fc5774 authored by Nadav Har'El's avatar Nadav Har'El Committed by Pekka Enberg
Browse files

open(): add O_DIRECTORY flag


This patch adds the O_DIRECTORY flag to sys_open(), which causes the open
to fail with ENOTDIR if the given file is any type of file but a directory.

We need this flag as part of a correct implementation of chdir() (which
should fail on a non-directory file), and it is also required for Linux
compatibility (the O_DIRECTORY flag exists since Linux 2.1.126).

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 33034397
No related branches found
No related tags found
No related merge requests found
...@@ -124,6 +124,12 @@ sys_open(char *path, int flags, mode_t mode, struct file **fpp) ...@@ -124,6 +124,12 @@ sys_open(char *path, int flags, mode_t mode, struct file **fpp)
if (vp->v_type == VDIR) if (vp->v_type == VDIR)
goto out_drele; goto out_drele;
} }
if (flags & O_DIRECTORY) {
if (vp->v_type != VDIR) {
error = ENOTDIR;
goto out_drele;
}
}
} }
vn_lock(vp); vn_lock(vp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment