mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 20:56:47 +08:00
fs/smartfs: Fix file size corruption when opening with truncate mode
If a existing file is opened with truncate mode e.g. fopen(file, "w+"), the file size will be incorrect after writing any data to the file. Before writing to the first sector, the reading is performed again. As a result, it makes an invalid file size. When a sector buffer is used, it must also write to the first sector.
This commit is contained in:
@@ -1765,8 +1765,8 @@ int smartfs_shrinkfile(FAR struct smartfs_mountpt_s *fs,
|
|||||||
remaining = 0;
|
remaining = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Are we retaining the sector it its entirety? */
|
/* Are we retaining the sector it its entirety? */
|
||||||
|
|
||||||
if (remaining >= available)
|
if (remaining >= available)
|
||||||
|
|||||||
Reference in New Issue
Block a user