From b7013fa7e549162af478d58ffc1f5ed369f58408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sun, 26 Jan 2020 15:46:57 +0100 Subject: 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 --- text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'text.c') 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; } -- cgit v1.2.3