ramfs: Remove open-mode checks in read and write hooks.
The VFS already does this for us, other filesystems don't check this either.
This commit is contained in:
@@ -1036,7 +1036,6 @@ ramfs_read(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
|
|||||||
// FUNCTION_START();
|
// FUNCTION_START();
|
||||||
Volume* volume = (Volume*)_volume->private_volume;
|
Volume* volume = (Volume*)_volume->private_volume;
|
||||||
Node* node = (Node*)_node->private_node;
|
Node* node = (Node*)_node->private_node;
|
||||||
FileCookie *cookie = (FileCookie*)_cookie;
|
|
||||||
|
|
||||||
// FUNCTION(("((%lu, %lu), %lld, %p, %lu)\n", node->GetDirID(),
|
// FUNCTION(("((%lu, %lu), %lld, %p, %lu)\n", node->GetDirID(),
|
||||||
// node->GetObjectID(), pos, buffer, *bufferSize));
|
// node->GetObjectID(), pos, buffer, *bufferSize));
|
||||||
@@ -1050,11 +1049,6 @@ ramfs_read(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
|
|||||||
if (!node->IsFile())
|
if (!node->IsFile())
|
||||||
SET_ERROR(error, B_BAD_VALUE);
|
SET_ERROR(error, B_BAD_VALUE);
|
||||||
|
|
||||||
// check, if reading is allowed
|
|
||||||
int rwMode = cookie->GetOpenMode() & O_RWMASK;
|
|
||||||
if (error == B_OK && rwMode != O_RDONLY && rwMode != O_RDWR)
|
|
||||||
SET_ERROR(error, B_FILE_ERROR);
|
|
||||||
|
|
||||||
// read
|
// read
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
if (File *file = dynamic_cast<File*>(node)) {
|
if (File *file = dynamic_cast<File*>(node)) {
|
||||||
@@ -1091,23 +1085,17 @@ ramfs_write(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
|
|||||||
if (!node->IsFile())
|
if (!node->IsFile())
|
||||||
SET_ERROR(error, B_BAD_VALUE);
|
SET_ERROR(error, B_BAD_VALUE);
|
||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
// check, if reading is allowed
|
// reset the position, if opened in append mode
|
||||||
int rwMode = cookie->GetOpenMode() & O_RWMASK;
|
if (cookie->GetOpenMode() & O_APPEND)
|
||||||
if (error == B_OK && rwMode != O_WRONLY && rwMode != O_RDWR)
|
pos = node->GetSize();
|
||||||
SET_ERROR(error, B_FILE_ERROR);
|
// write
|
||||||
if (error == B_OK) {
|
if (File *file = dynamic_cast<File*>(node)) {
|
||||||
// reset the position, if opened in append mode
|
error = file->WriteAt(pos, buffer, *bufferSize,
|
||||||
if (cookie->GetOpenMode() & O_APPEND)
|
bufferSize);
|
||||||
pos = node->GetSize();
|
} else {
|
||||||
// write
|
FATAL("Node %" B_PRIdINO " pretends to be a File, but isn't!\n",
|
||||||
if (File *file = dynamic_cast<File*>(node)) {
|
node->GetID());
|
||||||
error = file->WriteAt(pos, buffer, *bufferSize,
|
error = B_BAD_VALUE;
|
||||||
bufferSize);
|
|
||||||
} else {
|
|
||||||
FATAL("Node %" B_PRIdINO " pretends to be a File, but isn't!\n",
|
|
||||||
node->GetID());
|
|
||||||
error = B_BAD_VALUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// notify listeners
|
// notify listeners
|
||||||
|
|||||||
Reference in New Issue
Block a user