Skip to content

Commit f4566f1

Browse files
authored
[drivers/blk] 解决块设备写入不对齐数据失败的问题 #11103
1 parent 68a5c6a commit f4566f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/drivers/block/blk_dfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,16 @@ static ssize_t blk_fops_write(struct dfs_file *file, const void *buf, size_t cou
175175
if ((count - wsize) / bytes_per_sector != 0)
176176
{
177177
res = rt_device_write(dev, blk_pos, buf + wsize, (count - wsize) / bytes_per_sector);
178-
wsize += res * bytes_per_sector;
179-
blk_pos += res;
180178

181179
if (res != (count - wsize) / bytes_per_sector)
182180
{
181+
wsize += res * bytes_per_sector;
183182
*pos += wsize;
184183
return wsize;
185184
}
185+
186+
wsize += res * bytes_per_sector;
187+
blk_pos += res;
186188
}
187189

188190
/*

0 commit comments

Comments
 (0)