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:
SPRESENSE 2022-01-18 12:57:08 +09:00 committed by Alin Jerpelea
parent 60913d3b69
commit 8d591d5bc7

View File

@ -1765,8 +1765,8 @@ int smartfs_shrinkfile(FAR struct smartfs_mountpt_s *fs,
remaining = 0;
}
}
else
#endif
/* Are we retaining the sector it its entirety? */
if (remaining >= available)