From 3418bc6a59cf0d389b1ff0276002db8b999b9955 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 27 Aug 2026 00:20:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(fat32):=20c.Set=20=E5=86=99=E6=8C=87?= =?UTF-8?q?=E9=92=88=E8=AF=AF=E7=94=A8=E5=80=BC=E8=B5=8B=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20c.Set(c.Deref(ptr),val)=E2=80=94=E2=80=94r?= =?UTF-8?q?ead/write=20=E7=9A=84=20br/bw=E3=80=81dir=5Fsector=5Fout?= =?UTF-8?q?=E3=80=81ioctl=20=E6=89=87=E5=8C=BA=E5=8F=82=E6=95=B0=E4=BB=8E?= =?UTF-8?q?=E6=9C=AA=E5=86=99=E5=85=A5=E5=AF=BC=E8=87=B4=20ehdr=20?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E8=BF=94=E5=9B=9E0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKernel/Kernel/drivers/fs/fat32/fat32_diskio.vp | 10 +++++----- VKernel/Kernel/drivers/fs/fat32/fat32_types.vp | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/VKernel/Kernel/drivers/fs/fat32/fat32_diskio.vp b/VKernel/Kernel/drivers/fs/fat32/fat32_diskio.vp index ac101b4..232d782 100644 --- a/VKernel/Kernel/drivers/fs/fat32/fat32_diskio.vp +++ b/VKernel/Kernel/drivers/fs/fat32/fat32_diskio.vp @@ -63,17 +63,17 @@ def ioctl(pdrv: t.CUInt8T, cmd: t.CUInt8T, buff: t.CVoid | t.CPtr) -> types.DRES case types.GET_SECTOR_COUNT: disk_size: t.CUInt64T = ide.getDiskSize() if disk_size == 0: - c.Set(t.CUInt32T(buff, t.CPtr), 131072) + c.Set(c.Deref(t.CUInt32T(buff, t.CPtr)), 131072) elif disk_size > 0xFFFFFFFF: - c.Set(t.CUInt32T(buff, t.CPtr), 0xFFFFFFFF) + c.Set(c.Deref(t.CUInt32T(buff, t.CPtr)), 0xFFFFFFFF) else: - c.Set(t.CUInt32T(buff, t.CPtr), t.CUInt32T(disk_size)) + c.Set(c.Deref(t.CUInt32T(buff, t.CPtr)), t.CUInt32T(disk_size)) return types.DRESULT.RES_OK case types.GET_SECTOR_SIZE: - c.Set(t.CUInt16T(buff, t.CPtr), 512) + c.Set(c.Deref(t.CUInt16T(buff, t.CPtr)), 512) return types.DRESULT.RES_OK case types.GET_BLOCK_SIZE: - c.Set(t.CUInt32T(buff, t.CPtr), 1) + c.Set(c.Deref(t.CUInt32T(buff, t.CPtr)), 1) return types.DRESULT.RES_OK case types.CTRL_SYNC: return types.DRESULT.RES_OK diff --git a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp index cb24a5b..7d16660 100644 --- a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp +++ b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp @@ -910,8 +910,8 @@ class volinfo: _write32(c.Addr(self.win[0]), eo3 + 28, file_size) self.win_dirty = 1 self.win_flush() - c.Set(t.CUInt64T(dir_sector_out, t.CPtr), es3) - c.Set(t.CUInt32T(dir_offset_out, t.CPtr), eo3) + c.Set(c.Deref(t.CUInt64T(dir_sector_out, t.CPtr)), es3) + c.Set(c.Deref(t.CUInt32T(dir_offset_out, t.CPtr)), eo3) return FRESULT.FR_OK def dir_update_entry(self, dir_sector: t.CUInt64T, dir_offset: t.CUInt32T, first_cluster: t.CUInt32T, file_size: t.CUInt32T, attr: t.CUInt8T) -> FRESULT: @@ -1452,7 +1452,7 @@ class fileobj: def read(self, buff: t.CVoid | t.CPtr, btr: t.CUInt32T, br: t.CUInt32T | t.CPtr) -> FRESULT: 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) + c.Set(c.Deref(br), 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", @@ -1497,7 +1497,7 @@ class fileobj: _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) + c.Set(c.Deref(br), total_read) return FRESULT.FR_OK def _extend_to(self, target_pos: t.CUInt32T) -> FRESULT: @@ -1524,7 +1524,7 @@ class fileobj: def write(self, buff: t.CConst | t.CVoid | t.CPtr, btw: t.CUInt32T, bw: t.CUInt32T | t.CPtr) -> FRESULT: if not self.is_open: return FRESULT.FR_INVALID_OBJECT if not (self.flags & FA_WRITE): return FRESULT.FR_DENIED - c.Set(t.CUInt32T(bw, t.CPtr), 0) + c.Set(c.Deref(bw), 0) vol: volinfo | t.CPtr = self.vol remaining: t.CUInt32T = btw buf_ptr: t.CConst | t.CUInt8T | t.CPtr = t.CUInt8T(buff, t.CPtr) @@ -1576,7 +1576,7 @@ class fileobj: if self.file_pos % vol.cluster_size == 0: next_c: t.CUInt32T = vol.cluster_get_next(self.current_cluster) if next_c != 0: self.current_cluster = next_c - c.Set(t.CUInt32T(bw, t.CPtr), total_written) + c.Set(c.Deref(bw), total_written) return FRESULT.FR_OK def seek(self, offset: t.CUInt32T) -> FRESULT: