diff mbox series

handlers: copy_handler: Adapt nftw() usage for FreeBSD & musl

Message ID 4D751FC6-E7BD-4F15-AFCA-16A2691A9B20@siemens.com
State Accepted
Headers show
Series handlers: copy_handler: Adapt nftw() usage for FreeBSD & musl | expand

Commit Message

Storm, Christian Jan. 14, 2025, 3:56 p.m. UTC
Although `nftw()` is not called with the glibc-specific flag
`FTW_ACTIONRETVAL`, the `FTW_CONTINUE` and `FTW_STOP` flags
are used in the callback function `recurse_directory()`.

As those are semantically matching, just define them for musl
and non-Linux systems such as FreeBSD not having them.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 handlers/copy_handler.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/handlers/copy_handler.c b/handlers/copy_handler.c
index f7399e7e..a7e132fc 100644
--- a/handlers/copy_handler.c
+++ b/handlers/copy_handler.c
@@ -26,6 +26,17 @@ 
 #else
 #include <linux/fs.h>
 #endif
+/*
+ * Though the glibc-specific flag `FTW_ACTIONRETVAL` wasn't passed to `nftw()`,
+ * the specific return codes are used nonetheless. As they happen to match
+ * the defaults, just define them for musl and non-Linux systems. 
+ */
+#ifndef FTW_CONTINUE
+#define FTW_CONTINUE  0
+#endif
+#ifndef FTW_STOP
+#define FTW_STOP 1
+#endif
 #include <unistd.h>
 
 #include <pctl.h>