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:
Augustin Cavalier
2025-09-03 18:57:02 -04:00
parent f7c3fa972c
commit 64322ea7d0
@@ -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)) {
@@ -1090,11 +1084,6 @@ ramfs_write(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
// don't write anything but files // don't write anything but files
if (!node->IsFile()) if (!node->IsFile())
SET_ERROR(error, B_BAD_VALUE); SET_ERROR(error, B_BAD_VALUE);
if (error == B_OK) {
// check, if reading is allowed
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 (error == B_OK) {
// reset the position, if opened in append mode // reset the position, if opened in append mode
if (cookie->GetOpenMode() & O_APPEND) if (cookie->GetOpenMode() & O_APPEND)
@@ -1109,7 +1098,6 @@ ramfs_write(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
error = B_BAD_VALUE; error = B_BAD_VALUE;
} }
} }
}
// notify listeners // notify listeners
if (error == B_OK && cookie->NotificationIntervalElapsed(true)) if (error == B_OK && cookie->NotificationIntervalElapsed(true))
notify_if_stat_changed(volume, node); notify_if_stat_changed(volume, node);