[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/3] block/export/fuse: Fix build failure on FreeBSD
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 3/3] block/export/fuse: Fix build failure on FreeBSD |
Date: |
Mon, 24 Jan 2022 23:03:57 +0100 |
When building on FreeBSD we get:
[816/6851] Compiling C object libblockdev.fa.p/block_export_fuse.c.o
../block/export/fuse.c:612:16: error: use of undeclared identifier
'FALLOC_FL_KEEP_SIZE'
if (mode & FALLOC_FL_KEEP_SIZE) {
^
../block/export/fuse.c:616:16: error: use of undeclared identifier
'FALLOC_FL_PUNCH_HOLE'
if (mode & FALLOC_FL_PUNCH_HOLE) {
^
../block/export/fuse.c:619:22: error: use of undeclared identifier
'FALLOC_FL_KEEP_SIZE'
if (!(mode & FALLOC_FL_KEEP_SIZE)) {
^
3 errors generated.
FAILED: libblockdev.fa.p/block_export_fuse.c.o
Meson indeed reported FALLOC_FL_PUNCH_HOLE is not available:
C compiler for the host machine: cc (clang 10.0.1 "FreeBSD clang version
10.0.1")
Checking for function "fallocate" : NO
Checking for function "posix_fallocate" : YES
Header <linux/falloc.h> has symbol "FALLOC_FL_PUNCH_HOLE" : NO
Header <linux/falloc.h> has symbol "FALLOC_FL_ZERO_RANGE" : NO
...
Similarly to commit 304332039 ("block/export/fuse.c: fix musl build"),
guard the code requiring FALLOC_FL_KEEP_SIZE / FALLOC_FL_PUNCH_HOLE
definitions under CONFIG_FALLOCATE_PUNCH_HOLE #ifdef'ry.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
block/export/fuse.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/export/fuse.c b/block/export/fuse.c
index 3a158342c75..4c5d662be87 100644
--- a/block/export/fuse.c
+++ b/block/export/fuse.c
@@ -607,6 +607,7 @@ static bool fuse_fallocate_punch_hole(fuse_req_t req,
fuse_ino_t inode,
int mode, int64_t blk_len,
off_t offset, off_t *length)
{
+#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
FuseExport *exp = fuse_req_userdata(req);
if (mode & FALLOC_FL_KEEP_SIZE) {
@@ -629,6 +630,7 @@ static bool fuse_fallocate_punch_hole(fuse_req_t req,
fuse_ino_t inode,
*length -= size;
} while (ret == 0 && *length > 0);
}
+#endif /* CONFIG_FALLOCATE_PUNCH_HOLE */
return true;
}
--
2.34.1