From cecea8a5b37a0b2f3442ebd8905319b4567b53d5 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 7 Sep 2026 17:00:46 +0200 Subject: [PATCH 1/3] utils: Build with older compilers that do not default to C99 or newer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix building with older compilers that do not default to C99 or newer, resulting in errors like the following: ----------------------------------------------------------------------- In file included from ../bind-mount.c:24:0: ../utils.h: In function ‘cleanup_fdsetp’: ../utils.h:260:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (size_t i = 0; i < set->len; i++) ----------------------------------------------------------------------- This was the only occurrence of initial declarations in for loops, so the change also realigns the code style to what is used for the rest of the project. Signed-off-by: Antonio Ospite --- utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils.h b/utils.h index 0b4ec6ae..16ee546a 100644 --- a/utils.h +++ b/utils.h @@ -255,7 +255,9 @@ fdset_add (FdSet *set, int fd) static inline void cleanup_fdsetp (FdSet *set) { - for (size_t i = 0; i < set->len; i++) + size_t i; + + for (i = 0; i < set->len; i++) if (set->fds[i] >= 0) close (set->fds[i]); free (set->fds); From d6be2cf7cd7f46a96f0bfa385862b69a3573c4f9 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 7 Sep 2026 17:05:24 +0200 Subject: [PATCH 2/3] utils: Fix compilation warnings about -Wunused-parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix compilation warnings about `-Wunused-parameter` in `mount_setattr_wrapper` when building on older systems that do not have `__NR_mount_setattr`: ----------------------------------------------------------------------- ../utils.c: In function ‘mount_setattr_wrapper’: ../utils.c:1101:28: warning: unused parameter ‘dirfd’ [-Wunused-parameter] mount_setattr_wrapper (int dirfd, const char *path, unsigned int flags, ^ ../utils.c:1101:47: warning: unused parameter ‘path’ [-Wunused-parameter] mount_setattr_wrapper (int dirfd, const char *path, unsigned int flags, ^ ../utils.c:1101:66: warning: unused parameter ‘flags’ [-Wunused-parameter] mount_setattr_wrapper (int dirfd, const char *path, unsigned int flags, ^ ../utils.c:1102:43: warning: unused parameter ‘attr’ [-Wunused-parameter] struct mount_attr *attr, size_t size) ^ ../utils.c:1102:56: warning: unused parameter ‘size’ [-Wunused-parameter] struct mount_attr *attr, size_t size) ^ ----------------------------------------------------------------------- And while at it also fix potential similar issues in `pivot_root` on systems that do no have `__NR_pivot_root`. Signed-off-by: Antonio Ospite --- utils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils.c b/utils.c index 4d29aa9f..8dfcf6b8 100644 --- a/utils.c +++ b/utils.c @@ -903,6 +903,8 @@ pivot_root (const char * new_root, const char * put_old) #ifdef __NR_pivot_root return syscall (__NR_pivot_root, new_root, put_old); #else + (void) new_root; + (void) put_old; errno = ENOSYS; return -1; #endif @@ -1104,6 +1106,11 @@ mount_setattr_wrapper (int dirfd, const char *path, unsigned int flags, #ifdef __NR_mount_setattr return syscall (__NR_mount_setattr, dirfd, path, flags, attr, size); #else + (void) dirfd; + (void) path; + (void) flags; + (void) attr; + (void) size; errno = ENOSYS; return -1; #endif From a6ebe837246d3d8538ec91363509f832d7184ec9 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 7 Sep 2026 17:10:44 +0200 Subject: [PATCH 3/3] utils: Make sure __u64 is defined when declaring mount_attr fallback On some old systems it's possible that `__u64` has not been defined already when the fallback type for `mount_attr` is declared. So make sure `__u64` is defined by including `linux/types.h` explicitly. On systems where the file has been included already this causes no harm because the file should also have `#ifndef _LINUX_TYPES_H` protection guards. Signed-off-by: Antonio Ospite --- utils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.h b/utils.h index 16ee546a..7a26939d 100644 --- a/utils.h +++ b/utils.h @@ -289,6 +289,9 @@ void strappend_escape_for_mount_options (StringBuilder *dest, const char *src); #ifndef MOUNT_ATTR_RDONLY + +#include + struct mount_attr { __u64 attr_set;