From 15c5317b6cb784821af0d9e7db175c6925e34cdc Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Fri, 13 Jun 2025 12:58:57 -0700 Subject: [PATCH] sync: update sync script to strip _UAPI prefix in UAPI headers It's expected that kernel UAPI headers have #ifndef guards starting with __LINUX prefix, while in the kernel source code these guards are actually starting with _UAPI__LINUX. The stripping of _UAPI prefix is done (among other things) by kernel's scripts/headers_install.sh script. Given libbpf vendors its own UAPI header under include/uapi subdir, and those "internal" UAPI headers are sometimes used by libbpf users for convenience, let's stick to the __LINUX prefix rule and do that during the sync. Signed-off-by: Andrii Nakryiko --- scripts/sync-kernel.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/sync-kernel.sh b/scripts/sync-kernel.sh index f3f5190..4bbfdae 100755 --- a/scripts/sync-kernel.sh +++ b/scripts/sync-kernel.sh @@ -63,6 +63,7 @@ LIBBPF_TREE_FILTER="mkdir -p __libbpf/include/uapi/linux __libbpf/include/tools for p in "${!PATH_MAP[@]}"; do LIBBPF_TREE_FILTER+="git mv -kf ${p} __libbpf/${PATH_MAP[${p}]} && "$'\\\n' done +LIBBPF_TREE_FILTER+="find __libbpf/include/uapi/linux -type f -exec sed -i 's/_UAPI__LINUX/__LINUX/' {} + && "$'\\\n' LIBBPF_TREE_FILTER+="git rm --ignore-unmatch -f __libbpf/src/{Makefile,Build,test_libbpf.c,.gitignore} >/dev/null" cd_to() @@ -347,7 +348,7 @@ diff -u ${TMP_DIR}/linux-view.ls ${TMP_DIR}/github-view.ls echo "Comparing file contents..." CONSISTENT=1 for F in $(cat ${TMP_DIR}/linux-view.ls); do - if ! diff -u "${LINUX_ABS_DIR}/${F}" "${GITHUB_ABS_DIR}/${F}"; then + if ! diff -u <(sed 's/_UAPI__LINUX/__LINUX/' "${LINUX_ABS_DIR}/${F}") "${GITHUB_ABS_DIR}/${F}"; then echo "${LINUX_ABS_DIR}/${F} and ${GITHUB_ABS_DIR}/${F} are different!" CONSISTENT=0 fi