ramfs: Remove open-mode checks in read and write hooks.
The VFS already does this for us, other filesystems don't
check this either.
Diff
src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
@@ -1036,7 +1036,6 @@
Volume* volume = (Volume*)_volume->private_volume;
Node* node = (Node*)_node->private_node;
FileCookie *cookie = (FileCookie*)_cookie;
@@ -1050,11 +1049,6 @@
if (!node->IsFile())
SET_ERROR(error, B_BAD_VALUE);
int rwMode = cookie->GetOpenMode() & O_RWMASK;
if (error == B_OK && rwMode != O_RDONLY && rwMode != O_RDWR)
SET_ERROR(error, B_FILE_ERROR);
if (error == B_OK) {
if (File *file = dynamic_cast<File*>(node)) {
@@ -1091,23 +1085,17 @@
if (!node->IsFile())
SET_ERROR(error, B_BAD_VALUE);
if (error == B_OK) {
int rwMode = cookie->GetOpenMode() & O_RWMASK;
if (error == B_OK && rwMode != O_WRONLY && rwMode != O_RDWR)
SET_ERROR(error, B_FILE_ERROR);
if (error == B_OK) {
if (cookie->GetOpenMode() & O_APPEND)
pos = node->GetSize();
if (File *file = dynamic_cast<File*>(node)) {
error = file->WriteAt(pos, buffer, *bufferSize,
bufferSize);
} else {
FATAL("Node %" B_PRIdINO " pretends to be a File, but isn't!\n",
node->GetID());
error = B_BAD_VALUE;
}
if (cookie->GetOpenMode() & O_APPEND)
pos = node->GetSize();
if (File *file = dynamic_cast<File*>(node)) {
error = file->WriteAt(pos, buffer, *bufferSize,
bufferSize);
} else {
FATAL("Node %" B_PRIdINO " pretends to be a File, but isn't!\n",
node->GetID());
error = B_BAD_VALUE;
}
}