fix(fat32): c.Set 写指针误用值赋值,改为 c.Set(c.Deref(ptr),val)——read/write 的 br/bw、dir_sector_out、ioctl 扇区参数从未写入导致 ehdr 读取返回0
This commit is contained in:
1 parent
c0685fe6bd
commit
3418bc6a59
2 files changed
+11
-11
No files matched your search
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user