From 7c43956ebee4f4cf4e95a49421a6dceb92b8c5db Mon Sep 17 00:00:00 2001 From: Ruslan Isaev Date: Fri, 22 Aug 2025 17:50:42 +0300 Subject: [PATCH] vfs: introduce adjustable ISO9660 buffer length for file reading --- Makefile | 2 +- include/vfs.h | 2 ++ src/fs/vfs.c | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 12dfa44..613ac6a 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ test-cdrom: qemu-system-i386 -cdrom boot.iso -m 4096M -d int cdrom: - qemu-system-i386 -cdrom boot.iso -m 4096M + qemu-system-i386 -cdrom boot.iso -m 32M debug-cdrom: qemu-system-i386 -s -S -cdrom boot.iso -m 4096M -monitor stdio diff --git a/include/vfs.h b/include/vfs.h index e17214b..877b2d4 100644 --- a/include/vfs.h +++ b/include/vfs.h @@ -1,6 +1,8 @@ #ifndef VFS_H #define VFS_H +#define ISO_9660_BUFFER_LENGTH 2048 + #include #include "../include/atapi.h" #include "../include/lib9660.h" diff --git a/src/fs/vfs.c b/src/fs/vfs.c index 9f03275..6821115 100644 --- a/src/fs/vfs.c +++ b/src/fs/vfs.c @@ -71,9 +71,9 @@ size_t vfs_read_file(l9660_file *file, uint8_t* buffer) l9660_status status; for(;;) { - char buf[128]; + char buf[ISO_9660_BUFFER_LENGTH]; size_t read; - status = l9660_read(file, buf, 128, &read); + status = l9660_read(file, buf, ISO_9660_BUFFER_LENGTH, &read); if (status != L9660_OK) { printf("An error occurred during file read!\n"); @@ -97,8 +97,8 @@ size_t vfs_read_file_length(l9660_file *file, uint8_t* buffer, size_t length) l9660_status status; while(total_read < length) { - char buf[128]; - size_t to_read = (length - total_read) < 128 ? (length - total_read) : 128; + char buf[ISO_9660_BUFFER_LENGTH]; + size_t to_read = (length - total_read) < ISO_9660_BUFFER_LENGTH ? (length - total_read) : ISO_9660_BUFFER_LENGTH; size_t read = 0; status = l9660_read(file, buf, to_read, &read);