Improve crash resilience in Linux

Syncing the directory is a required step to ensure resilience.
Also create the temporary file with O_EXCL to ensure to don't
use a stale copy that may link to the original copy.
This commit is contained in:
Andrea Mazzoleni 2018-06-04 22:14:23 +02:00
parent c696c56df1
commit 473819467f
5 changed files with 87 additions and 6 deletions

View file

@ -41,6 +41,7 @@ void test(void)
s = sopen_multi_write(STREAM_MAX);
for (i = 0; i < STREAM_MAX; ++i) {
snprintf(file, sizeof(file), "stream%u.bin", i);
remove(file);
if (sopen_multi_file(s, i, file) != 0) {
/* LCOV_EXCL_START */
exit(EXIT_FAILURE);