From 1f7e7501660123ff8f26e8c65e75c2b282b933ef Mon Sep 17 00:00:00 2001 From: dzwdz Date: Fri, 8 Jul 2022 14:40:44 +0200 Subject: syscall/fs_respond: get the file id from the buf argument Previously, file ids could only be positive integers, so their range was 31 bits - not enough to represent the entire memory. Now, pointers can be safely used as file ids. --- src/kernel/arch/i386/driver/fsroot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/kernel/arch/i386/driver/fsroot.c') diff --git a/src/kernel/arch/i386/driver/fsroot.c b/src/kernel/arch/i386/driver/fsroot.c index ccba0b6..e16dd80 100644 --- a/src/kernel/arch/i386/driver/fsroot.c +++ b/src/kernel/arch/i386/driver/fsroot.c @@ -45,6 +45,7 @@ static void req_preprocess(struct vfs_request *req, size_t max_len) { static int handle(struct vfs_request *req) { assert(req->caller); + int id = (int)req->id; switch (req->type) { case VFSOP_OPEN: if (req->flags & OPEN_CREATE) return -1; @@ -65,7 +66,7 @@ static int handle(struct vfs_request *req) { return -1; case VFSOP_READ: - switch (req->id) { + switch (id) { case HANDLE_ROOT: { // TODO document directory read format const char src[] = @@ -106,7 +107,7 @@ static int handle(struct vfs_request *req) { char buf[512]; uint32_t sector = req->offset / 512; size_t len = min(req->output.len, 512 - ((size_t)req->offset & 511)); - ata_read(req->id - HANDLE_ATA, sector, buf); + ata_read(id - HANDLE_ATA, sector, buf); virt_cpy_to(req->caller->pages, req->output.buf, buf, len); return len; } @@ -114,7 +115,7 @@ static int handle(struct vfs_request *req) { } case VFSOP_WRITE: - switch (req->id) { + switch (id) { case HANDLE_VGA: { void *vga = (void*)0xB8000; req_preprocess(req, 80*25*2); -- cgit v1.2.3