mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-03 21:30:14 -05:00
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:
parent
c696c56df1
commit
473819467f
5 changed files with 87 additions and 6 deletions
|
|
@ -112,7 +112,8 @@ int sopen_multi_file(STREAM* s, unsigned i, const char* file)
|
|||
|
||||
pathcpy(s->handle[i].path, sizeof(s->handle[i].path), file);
|
||||
|
||||
f = open(file, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_SEQUENTIAL, 0600);
|
||||
/* O_EXCL to be resilent ensure to always create a new file and not use a stale link to the original file */
|
||||
f = open(file, O_WRONLY | O_CREAT | O_EXCL | O_BINARY | O_SEQUENTIAL, 0600);
|
||||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
return -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue