Make sure configuration is saved to storage device
Config file is written to a temp file and then it is renamed to the original config file. However, it is possible that the rename operation will be commited to storage while file data will be still in cache causing original config file to be empty or partially written in case of a system reboot without a clean shutdown. Make this less likely to occur by forcing the data to be written to the storage device before renaming the file. Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
parent
6aaa661af1
commit
a218e1ded4
6 changed files with 47 additions and 0 deletions
|
@ -418,6 +418,14 @@ int os_file_exists(const char *fname)
|
|||
}
|
||||
|
||||
|
||||
int os_fdatasync(FILE *stream)
|
||||
{
|
||||
if (!fflush(stream))
|
||||
return fdatasync(fileno(stream));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#ifndef WPA_TRACE
|
||||
void * os_zalloc(size_t size)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue