xfstests: fix musl build (linux/types.h, RWH_WRITE_LIFE_NOT_SET)

fs-monitor.c uses __s32/__u32 without <linux/types.h>, and rw_hint.c
uses RWH_WRITE_LIFE_NOT_SET which musl's headers don't define. Add the
missing include and a guarded fallback define.

AI-Generated: Uses Claude Code

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-09-29 09:57:22 -07:00
1 parent a1d94f9fdc
commit 756cde9a4d
3 files changed
+55

No files matched your search

@@ -0,0 +1,24 @@
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Tue, 29 Sep 2026 02:03:26 +0000
Subject: [PATCH] fs-monitor: include linux/types.h for __s32/__u32
The local fallback definition of "struct fanotify_event_info_error"
(used when the libc's <sys/fanotify.h> predates FAN_FS_ERROR) uses the
kernel-style __s32/__u32 typedefs. glibc's headers happen to pull
these in transitively via other system headers, but musl does not, so
building against musl fails with "unknown type name '__s32'/'__u32'"
unless <linux/types.h> is included directly.
Upstream-Status: Pending
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
--- a/src/fs-monitor.c
+++ b/src/fs-monitor.c
@@ -12,6 +12,7 @@
#include <sys/fanotify.h>
#include <sys/types.h>
#include <unistd.h>
+#include <linux/types.h>
#ifndef FAN_FS_ERROR
#define FAN_FS_ERROR 0x00008000
@@ -0,0 +1,29 @@
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Tue, 29 Sep 2026 02:03:26 +0000
Subject: [PATCH] rw_hint: add fallback define for RWH_WRITE_LIFE_NOT_SET
The musl <fcntl.h> shipped in this toolchain mistakenly names the
"not set" write-hint constant RWF_WRITE_LIFE_NOT_SET instead of the
kernel uapi's RWH_WRITE_LIFE_NOT_SET (the other RWH_WRITE_LIFE_*
values are spelled correctly), while glibc's <bits/fcntl-linux.h>
defines RWH_WRITE_LIFE_NOT_SET as expected. Guard a local fallback
definition so the test builds against either libc, without needing to
pull in <linux/fcntl.h> and risk clashing with musl's own F_*_RW_HINT
macro values.
Upstream-Status: Pending
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
--- a/src/rw_hint.c
+++ b/src/rw_hint.c
@@ -7,6 +7,10 @@
#include <string.h>
#include <fcntl.h>
+#ifndef RWH_WRITE_LIFE_NOT_SET
+#define RWH_WRITE_LIFE_NOT_SET 0
+#endif
+
int main(int argc, char **argv)
{
uint64_t hint = -1;
@@ -13,6 +13,8 @@ SRC_URI = "git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git;branch=master;ta
file://0002-Add-missing-STATX_ATTR_-defines-from-musl-sys-stat.h.patch \
file://0001-bstat-use-uint32_t-instead-of-__uint32_t-to-fix-buil.patch \
file://0001-locktest-do-not-tie-struct-delegation-to-the-F_GETDE.patch \
file://0003-fs-monitor-include-linux-types.h-for-__s32-__u32.patch \
file://0004-rw_hint-add-fallback-define-for-RWH_WRITE_LIFE_NOT_.patch \
"