aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-01-26 15:46:57 +0100
committerMarc André Tanner <mat@brain-dump.org>2020-01-26 15:46:57 +0100
commitb7013fa7e549162af478d58ffc1f5ed369f58408 (patch)
treedd36b399dcfd4de3be22ee6b276e08970470aecc
parent33ecbde6688ef887fa9ab4d2bddad9a021adff3b (diff)
downloadvis-b7013fa7e549162af478d58ffc1f5ed369f58408.tar.gz
vis-b7013fa7e549162af478d58ffc1f5ed369f58408.tar.xz
text: ignore fsync(2) errors on unsupported directory descriptors
When saving a file by atomically renaming it to its final destination, we fsync(2) the parent directory to make sure the new directory entry is persisted. However, not all file systems support fsync on file descriptors referring to directories. As a result the save operation fails and subsequent attempts result in warnings regarding outdated file content, even though the data has most likely been successfully written. Ignoring this particular error seems fine, because it is a permanent limitation of the file system and not a temporary failure. Fixes #792
-rw-r--r--text.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/text.c b/text.c
index 35d1bcd..8b45e24 100644
--- a/text.c
+++ b/text.c
@@ -921,7 +921,7 @@ static bool text_save_commit_atomic(TextSave *ctx) {
if (dir == -1)
return false;
- if (fsync(dir) == -1) {
+ if (fsync(dir) == -1 && errno != EINVAL) {
close(dir);
return false;
}