diff options
author | ed <ed@FreeBSD.org> | 2010-03-21 20:43:23 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2010-03-21 20:43:23 +0000 |
commit | 61565034678feb77b6c58414a124a3e2da5b51e7 (patch) | |
tree | bd53b22130f2318dc178cfea963b4c5affe6d99a /sys/kern | |
parent | ef7941cba28fcad604cef37d54a4b24af415b5f2 (diff) | |
download | FreeBSD-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/kern')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 4 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 4 |
2 files changed, 8 insertions, 0 deletions
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) { |