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