61 lines
2.3 KiB
Diff
61 lines
2.3 KiB
Diff
From 4c02ff62f40497335da185cc4b45c2ba43fb609b Mon Sep 17 00:00:00 2001
|
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
Date: Thu, 1 May 2025 10:59:17 +0100
|
|
Subject: [PATCH] file: Fix do_fallocate debugging on Alpine
|
|
|
|
Alpine has some weird/old kernel that doesn't support
|
|
FALLOC_FL_ZERO_RANGE but does support FALLOC_FL_PUNCH_HOLE, so the
|
|
debugging I added in commit ecf6b15fa8 failed to compile with:
|
|
|
|
file.c: In function 'do_fallocate':
|
|
file.c:958:27: error: 'FALLOC_FL_ZERO_RANGE' undeclared (first use in this function)
|
|
958 | mode_ & FALLOC_FL_ZERO_RANGE ? " FALLOC_FL_ZERO_RANGE" : "",
|
|
| ^~~~~~~~~~~~~~~~~~~~
|
|
file.c:958:27: note: each undeclared identifier is reported only once for each function it appears in
|
|
make[3]: *** [Makefile:666: nbdkit_file_plugin_la-file.lo] Error 1
|
|
|
|
Fixes: commit ecf6b15fa84a02b74ea969f06552c82ee418b9b4
|
|
(cherry picked from commit 419a347054f81c53706637feddbc5008beab77d3)
|
|
---
|
|
plugins/file/file.c | 15 +++++++++++++--
|
|
1 file changed, 13 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/plugins/file/file.c b/plugins/file/file.c
|
|
index 01ad1ef2..32c5e2b7 100644
|
|
--- a/plugins/file/file.c
|
|
+++ b/plugins/file/file.c
|
|
@@ -875,7 +875,7 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset,
|
|
return 0;
|
|
}
|
|
|
|
-#if defined (FALLOC_FL_PUNCH_HOLE) || defined (FALLOC_FL_ZERO_RANGE)
|
|
+#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE)
|
|
static int
|
|
do_fallocate (int fd, int mode_, off_t offset, off_t len)
|
|
{
|
|
@@ -884,9 +884,20 @@ do_fallocate (int fd, int mode_, off_t offset, off_t len)
|
|
r = fallocate (fd, mode_, offset, len);
|
|
|
|
if (file_debug_zero)
|
|
- nbdkit_debug ("fallocate ([%s%s ], %" PRIu64 ", %" PRIu64") => %d (%d)",
|
|
+ nbdkit_debug ("fallocate (["
|
|
+#if defined(FALLOC_FL_PUNCH_HOLE)
|
|
+ "%s"
|
|
+#endif
|
|
+#if defined(FALLOC_FL_ZERO_RANGE)
|
|
+ "%s"
|
|
+#endif
|
|
+ " ], %" PRIu64 ", %" PRIu64") => %d (%d)",
|
|
+#if defined(FALLOC_FL_PUNCH_HOLE)
|
|
mode_ & FALLOC_FL_PUNCH_HOLE ? " FALLOC_FL_PUNCH_HOLE" : "",
|
|
+#endif
|
|
+#if defined(FALLOC_FL_ZERO_RANGE)
|
|
mode_ & FALLOC_FL_ZERO_RANGE ? " FALLOC_FL_ZERO_RANGE" : "",
|
|
+#endif
|
|
(uint64_t) offset, (uint64_t) len, r,
|
|
r == -1 ? errno : 0);
|
|
|
|
--
|
|
2.47.1
|
|
|