From 51c74750311e444f9c60f8ed2697b33e1621b106 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 27 Aug 2026 00:08:52 +0800 Subject: [PATCH] =?UTF-8?q?debug(fat32):=20read=20=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=8A=B6=E6=80=81(size/first=5Fcluster/pos)?= =?UTF-8?q?=E4=B8=8E=E5=AE=9E=E9=99=85=E8=AF=BB=E5=8F=96=E5=AD=97=E8=8A=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=AE=9A=E4=BD=8D=20ehdr=20=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E5=A4=B1=E8=B4=A5=E6=A0=B9=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKernel/Kernel/drivers/fs/fat32/fat32_types.vp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp index 935fb31..cb24a5b 100644 --- a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp +++ b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp @@ -4,7 +4,8 @@ import spinlock import string import fat32_diskio as diskio import fat32_time as ftime - +import viperlib +import drivers.serial.uart.serial as serial def _read32(buf: t.CUInt8T | t.CPtr, off: t.CUInt32T) -> t.CUInt32T: return t.CUInt32T(buf[off]) | (t.CUInt32T(buf[off + 1]) << 8) | (t.CUInt32T(buf[off + 2]) << 16) | (t.CUInt32T(buf[off + 3]) << 24) @@ -1452,6 +1453,11 @@ class fileobj: if not self.is_open: return FRESULT.FR_INVALID_OBJECT if not (self.flags & FA_READ): return FRESULT.FR_DENIED c.Set(t.CUInt32T(br, t.CPtr), 0) + # [RD-DIAG] 定位 read_len<64(ehdr 读取失败)根因:打印文件状态 + _rdb: t.CArray[t.CChar, 160] + viperlib.snprintf(c.Addr(_rdb), 160, "[fat32] read: size=%lu fc=%lu cc=%lu pos=%lu btr=%lu\n", + self.file_size, self.first_cluster, self.current_cluster, self.file_pos, btr) + serial.puts(c.Addr(_rdb)) vol: volinfo | t.CPtr = self.vol remaining: t.CUInt32T = btr buf_ptr: t.CUInt8T | t.CPtr = t.CUInt8T(buff, t.CPtr) @@ -1487,6 +1493,10 @@ class fileobj: next_c: t.CUInt32T = vol.cluster_get_next(self.current_cluster) if next_c == 0: break self.current_cluster = next_c + # [RD-DIAG] 打印实际读取字节数 + _rdb2: t.CArray[t.CChar, 96] + viperlib.snprintf(c.Addr(_rdb2), 96, "[fat32] read done: br=%lu\n", total_read) + serial.puts(c.Addr(_rdb2)) c.Set(t.CUInt32T(br, t.CPtr), total_read) return FRESULT.FR_OK