Disallow opening dirs without O_DIRECTORY and vice versa

This commit is contained in:
Mark
2020-01-17 13:24:41 +02:00
parent fdde790665
commit 2d6b461d0f
+6
View File
@@ -184,6 +184,10 @@ int vfs_open_vnode(struct vfs_ioctx *ctx, struct ofile *fd, struct vnode *node,
_assert(node);
if (opt & O_DIRECTORY) {
if (node->type != VN_DIR) {
return -ENOTDIR;
}
if ((opt & O_ACCMODE) != O_RDONLY) {
return -EACCES;
}
@@ -198,6 +202,8 @@ int vfs_open_vnode(struct vfs_ioctx *ctx, struct ofile *fd, struct vnode *node,
}
return 0;
} else if (node->type == VN_DIR || node->type == VN_MNT) {
return -EISDIR;
}
// Check node access