From 81458ef8a650ba28e85f92ddd4fdea65f98b1a52 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 13 Feb 2023 23:12:23 -0500 Subject: [PATCH] kernel/vfs: Remove read sizing hack in common_file_io_vec_pages. All drivers using IORequest should have any problems here already caught by it, and overruns in other drivers would overrun the buffer and cause corruptions, so we should no longer silently be ignoring this, presuming it is still a problem at all. As the TODO comment indicated that this logic could also be used for writes if this wasn't a problem, I have added a separate TODO for that. --- src/system/kernel/fs/vfs.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index a07c1bfa9b..4ed96e0251 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -3489,6 +3489,7 @@ common_file_io_vec_pages(struct vnode* vnode, void* cookie, if (!doWrite && vecOffset == 0) { // now directly read the data from the device // the first file_io_vec can be read directly + // TODO: we could also write directly if (fileVecs[0].length < (off_t)numBytes) size = fileVecs[0].length; @@ -3506,17 +3507,6 @@ common_file_io_vec_pages(struct vnode* vnode, void* cookie, if (status != B_OK) return status; - // TODO: this is a work-around for buggy device drivers! - // When our own drivers honour the length, we can: - // a) also use this direct I/O for writes (otherwise, it would - // overwrite precious data) - // b) panic if the term below is true (at least for writes) - if ((off_t)size > fileVecs[0].length) { - //dprintf("warning: device driver %p doesn't respect total length " - // "in read_pages() call!\n", ref->device); - size = fileVecs[0].length; - } - ASSERT((off_t)size <= fileVecs[0].length); // If the file portion was contiguous, we're already done now