summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-03-21 20:43:23 +0000
committered <ed@FreeBSD.org>2010-03-21 20:43:23 +0000
commit61565034678feb77b6c58414a124a3e2da5b51e7 (patch)
treebd53b22130f2318dc178cfea963b4c5affe6d99a /sys
parentef7941cba28fcad604cef37d54a4b24af415b5f2 (diff)
downloadFreeBSD-src-61565034678feb77b6c58414a124a3e2da5b51e7.zip
FreeBSD-src-61565034678feb77b6c58414a124a3e2da5b51e7.tar.gz
Actually make O_DIRECTORY work.
According to POSIX open() must return ENOTDIR when the path name does not refer to a path name. Change vn_open() to respect this flag. This also simplifies the Linuxolator a bit.
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/linux/linux_file.c8
-rw-r--r--sys/kern/vfs_syscalls.c4
-rw-r--r--sys/kern/vfs_vnops.c4
3 files changed, 10 insertions, 6 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 4e33eaa..9ff1cf0 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -128,6 +128,8 @@ linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mod
bsd_flags |= O_DIRECT;
if (l_flags & LINUX_O_NOFOLLOW)
bsd_flags |= O_NOFOLLOW;
+ if (l_flags & LINUX_O_DIRECTORY)
+ bsd_flags |= O_DIRECTORY;
/* XXX LINUX_O_NOATIME: unable to be easily implemented. */
error = kern_openat(td, dirfd, path, UIO_SYSSPACE, bsd_flags, mode);
@@ -154,12 +156,6 @@ linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mod
PROC_UNLOCK(p);
sx_sunlock(&proctree_lock);
}
- if (l_flags & LINUX_O_DIRECTORY) {
- if (fp->f_type != DTYPE_VNODE ||
- fp->f_vnode->v_type != VDIR) {
- error = ENOTDIR;
- }
- }
fdrop(fp, td);
/*
* XXX as above, fdrop()/kern_close() pair is racy.
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 9d535b5..bcc3cbb 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -4428,6 +4428,10 @@ fhopen(td, uap)
error = EOPNOTSUPP;
goto bad;
}
+ if (vp->v_type != VDIR && fmode & O_DIRECTORY) {
+ error = ENOTDIR;
+ goto bad;
+ }
accmode = 0;
if (fmode & (FWRITE | O_TRUNC)) {
if (vp->v_type == VDIR) {
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index d0b713c..a16fa67 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -200,6 +200,10 @@ restart:
error = EOPNOTSUPP;
goto bad;
}
+ if (vp->v_type != VDIR && fmode & O_DIRECTORY) {
+ error = ENOTDIR;
+ goto bad;
+ }
accmode = 0;
if (fmode & (FWRITE | O_TRUNC)) {
if (vp->v_type == VDIR) {
OpenPOWER on IntegriCloud