1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
https://github.com/util-linux/util-linux/commit/67fd3bf434299c701c9361dca509d752e220ea7f
From 67fd3bf434299c701c9361dca509d752e220ea7f Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 3 Sep 2026 09:45:29 +0200
Subject: [PATCH] lib/fileutils: fix unused parameter warnings without
SYS_openat2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
On systems without SYS_openat2 (older kernels), ul_openat_resolve()
is a stub that returns -ENOSYS, making all parameters unused. With
-Werror=unused-parameter this breaks the build.
Move the #ifdef around the whole function so each branch has its own
declaration — the SYS_openat2 branch uses all parameters normally,
the fallback branch marks them __unused__.
Fixes: fb8e26535 ("libmount: pin source path with openat2() for restricted users")
Signed-off-by: Karel Zak <kzak@redhat.com>
(cherry picked from commit a471b62e732a491f1abe42450352fb0f9b5b43ea)
---
lib/fileutils.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/lib/fileutils.c b/lib/fileutils.c
index 89f1e216984..80b69eea271 100644
--- a/lib/fileutils.c
+++ b/lib/fileutils.c
@@ -440,10 +440,10 @@ char *ul_basename(char *path)
return p;
}
+#if defined(SYS_openat2)
int ul_openat_resolve(int dirfd, const char *path, int flags,
mode_t mode, unsigned long long resolve)
{
-#if defined(SYS_openat2)
struct open_how how = {
.flags = (__u64) flags,
.mode = (__u64) mode,
@@ -451,11 +451,19 @@ int ul_openat_resolve(int dirfd, const char *path, int flags,
};
return syscall(SYS_openat2, dirfd, path, &how, sizeof(how));
+}
#else
+int ul_openat_resolve(
+ int dirfd __attribute__((__unused__)),
+ const char *path __attribute__((__unused__)),
+ int flags __attribute__((__unused__)),
+ mode_t mode __attribute__((__unused__)),
+ unsigned long long resolve __attribute__((__unused__)))
+{
errno = ENOSYS;
return -1;
-#endif
}
+#endif
int ul_open_no_symlinks(const char *path, int flags, mode_t mode)
{
|