From f78bc27f353ed05595ede3eb895fb493412569d7 Mon Sep 17 00:00:00 2001 From: Gregory Bowne Date: Thu, 8 Jan 2026 21:03:10 -0800 Subject: [PATCH 1/2] Fix extern declaration for disk_read_sector function --- kernel/fat12.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fat12.h b/kernel/fat12.h index 730b144..9615cc7 100644 --- a/kernel/fat12.h +++ b/kernel/fat12.h @@ -58,7 +58,7 @@ typedef struct { // You must implement this in your disk driver (e.g., floppy.c) // Returns 0 on success, non-zero on error. -extern int disk_read_sector(uint32_t lba, uint8_t *buffer); +int disk_read_sector(uint32_t lba, uint8_t *buffer); void fat12_init(); file_t fat12_open(const char *filename); From c0e7ab6be06710fd1f183c03ffe67381b1b7c1ab Mon Sep 17 00:00:00 2001 From: Gregory Bowne Date: Thu, 8 Jan 2026 21:10:35 -0800 Subject: [PATCH 2/2] Fix k_memcmp return logic and add disk_read_sector Refactor k_memcmp to return correct difference and add disk_read_sector function. --- kernel/fat12.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/fat12.c b/kernel/fat12.c index 7f0a1da..a296ea2 100644 --- a/kernel/fat12.c +++ b/kernel/fat12.c @@ -15,9 +15,16 @@ static uint8_t g_sector_buffer[FAT12_SECTOR_SIZE]; static int k_memcmp(const void *s1, const void *s2, uint32_t n) { const uint8_t *p1 = (const uint8_t *)s1; const uint8_t *p2 = (const uint8_t *)s2; + for (uint32_t i = 0; i < n; i++) { - if (p1[i] != p2[i]) return p1[i] - p2[i]; + if (p1[i] != p2[i]) { + // Correct way to return the difference: + // If p1[i] > p2[i], returns positive. + // If p1[i] < p2[i], returns negative. + return (int)p1[i] - (int)p2[i]; + } } + return 0; } @@ -182,3 +189,8 @@ uint32_t fat12_read(file_t *file, uint8_t *buffer, uint32_t bytes_to_read) { return total_read; } + +int disk_read_sector(uint32_t lba, uint8_t *buffer) { + // For now, do nothing and return success + return 0; +}