chantra / rpms / librepo

Forked from rpms/librepo 2 years ago
Clone

Blame SOURCES/0001-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch

3c1258
From 33be80700bc594f34818ce697493c17e70430390 Mon Sep 17 00:00:00 2001
3c1258
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
3c1258
Date: Mon, 17 May 2021 08:50:25 +0200
3c1258
Subject: [PATCH] Recover from fsync fail on read-only filesystem
3c1258
 (RhBug:1956361)
3c1258
3c1258
When `fsync` fails due to the file not supporting synchronization just log
3c1258
the problem instead of failing the whole dnf run. This happens for
3c1258
example with filesystems mounted read-only in which case there is no
3c1258
point to `fsync` anyway.
3c1258
3c1258
Currently we also ignore return values from `FSETXATTR` which also fails
3c1258
on read-only filesystem (so no checksum cache is set). This is fine however
3c1258
since the checksum is recomputed when needed, dnf is just a bit slower.
3c1258
3c1258
https://bugzilla.redhat.com/show_bug.cgi?id=1956361
3c1258
---
3c1258
 librepo/checksum.c | 10 +++++++---
3c1258
 1 file changed, 7 insertions(+), 3 deletions(-)
3c1258
3c1258
diff --git a/librepo/checksum.c b/librepo/checksum.c
3c1258
index db37040..6bba53c 100644
3c1258
--- a/librepo/checksum.c
3c1258
+++ b/librepo/checksum.c
3c1258
@@ -266,9 +266,13 @@ lr_checksum_fd_compare(LrChecksumType type,
3c1258
     *matches = (strcmp(expected, checksum)) ? FALSE : TRUE;
3c1258
 
3c1258
     if (fsync(fd) != 0) {
3c1258
-        g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
3c1258
-                    "fsync failed: %s", strerror(errno));
3c1258
-        return FALSE;
3c1258
+        if (errno == EROFS || errno == EINVAL) {
3c1258
+            g_debug("fsync failed: %s", strerror(errno));
3c1258
+        } else {
3c1258
+            g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
3c1258
+                        "fsync failed: %s", strerror(errno));
3c1258
+            return FALSE;
3c1258
+        }
3c1258
     }
3c1258
 
3c1258
     if (caching && *matches && timestamp != -1) {
3c1258
-- 
3c1258
2.31.1
3c1258