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:
parent
60913d3b69
commit
8d591d5bc7
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user