kernel/devfs: Check whether the node is a directory in devfs_open.
Same checks as other filesystems. Fixes "cp file /dev/some/block/device". Change-Id: Ic4bd04972247b94ac4eaa6e211fe6cb1c53f3975 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9084 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
2d3b5776e7
commit
240f1a0e91
@@ -1113,6 +1113,11 @@ devfs_open(fs_volume* _volume, fs_vnode* _vnode, int openMode,
|
||||
struct devfs_cookie* cookie;
|
||||
status_t status = B_OK;
|
||||
|
||||
if (S_ISDIR(vnode->stream.type) && (openMode & O_RWMASK) != O_RDONLY)
|
||||
return B_IS_A_DIRECTORY;
|
||||
if ((openMode & O_DIRECTORY) != 0 && !S_ISDIR(vnode->stream.type))
|
||||
return B_NOT_A_DIRECTORY;
|
||||
|
||||
cookie = (struct devfs_cookie*)malloc(sizeof(struct devfs_cookie));
|
||||
if (cookie == NULL)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
Reference in New Issue
Block a user