Skip to content

Commit 053f9bc

Browse files
authored
[fix][blk]解决块设备写入不对齐数据失败的问题
1 parent c39e92f commit 053f9bc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

components/drivers/block/blk_dfs.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,18 @@ 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+
else
186+
{
187+
wsize += res * bytes_per_sector;
188+
blk_pos += res;
189+
}
186190
}
187191

188192
/*

0 commit comments

Comments
 (0)