From 6c8c7eeceb8e40ae9a59ccf29b6f6ea1173942b6 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Thu, 1 Dec 2022 03:17:00 -0500 Subject: [PATCH] LU-16335 build: remove _GNU_SOURCE dependency in lustre_user.h The lustre_user.h header uses the non-standard strchrnul() function in userspace. This will always leads to LC_IOC_REMOVE_ENTRY configure check to fail, and in the end "lfs rm_entry" always returns -ENOTSUP. Implement an alternative approach to avoid external dependencies on the lustre_user.h header. Also, LC_IOC_REMOVE_ENTRY is itself unnecessary, the code can check for LL_IOC_REMOVE_ENTRY directly. Replace the NFS-specific -ENOTSUP error return code with -EOPNOTSUPP. Fix the compile test_400[ab] checks to not use "-std=c99" to verify that the uapi headers are usable without this dependency. Lustre-change: https://review.whamcloud.com/49328 Lustre-commit: efc5c8d4de60d394344506f7cfb188eaf04a4bac Fixes: b59835f8b6 ("LU-13903 utils: have liblustreapi support Linux client") Fixes: 7a7309fa84 ("LU-13274 uapi: make lustre UAPI headers C99 compliant") Fixes: 6331eadbd6 ("LU-15420 uapi: avoid gcc-11 -Werror=stringop-overread") Signed-off-by: Lai Siyao Change-Id: If42743a2148c317b8a9b701ceb5d08bac5149f5f Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49711 Tested-by: jenkins Tested-by: Maloo --- lustre/include/uapi/linux/lustre/lustre_user.h | 6 +++++- lustre/tests/sanity.sh | 15 ++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lustre/include/uapi/linux/lustre/lustre_user.h b/lustre/include/uapi/linux/lustre/lustre_user.h index cab8535..2e26b58 100644 --- a/lustre/include/uapi/linux/lustre/lustre_user.h +++ b/lustre/include/uapi/linux/lustre/lustre_user.h @@ -2007,7 +2007,11 @@ static inline char *changelog_rec_name(const struct changelog_rec *rec) static inline char *changelog_rec_sname(const struct changelog_rec *rec) { - return strchrnul(changelog_rec_name(rec), '\0') + 1; + char *str = changelog_rec_name(rec); + + while (*str != '\0') + str++; + return str + 1; } static inline __kernel_size_t changelog_rec_snamelen(const struct changelog_rec *rec) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 8bb9216..8ab135f 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -24660,18 +24660,19 @@ test_400a() { # LU-1606, was conf-sanity test_74 local prefix=/usr/include/lustre local prog - # Oleg removes c files in his test rig so test if any c files exist - [ -z "$(ls -A $LUSTRE_TESTS_API_DIR)" ] && \ - skip_env "Needed c test files are missing" + # Oleg removes .c files in his test rig so test if any c files exist + [[ -n "$(ls -A $LUSTRE_TESTS_API_DIR)" ]] || + skip_env "Needed .c test files are missing" if ! [[ -d $prefix ]]; then # Assume we're running in tree and fixup the include path. - extra_flags+=" -I$LUSTRE/../lnet/include/uapi -I$LUSTRE/include/uapi -I$LUSTRE/include" - extra_flags+=" -L$LUSTRE/utils/.lib" + extra_flags+=" -I$LUSTRE/../lnet/include/uapi" + extra_flags+=" -I$LUSTRE/include/uapi -I$LUSTRE/include" + extra_flags+=" -L$LUSTRE/utils/.libs" fi for prog in $LUSTRE_TESTS_API_DIR/*.c; do - $CC -Wall -Werror -std=c99 $extra_flags -o $out $prog -llustreapi || + $CC -Wall -Werror $extra_flags -o $out $prog -llustreapi || error "client api broken" done rm -f $out @@ -24703,7 +24704,7 @@ test_400b() { # LU-1606, LU-5011 continue # lustre_ioctl.h is internal header fi - $CC -Wall -Werror -std=c99 -include $header -c -x c /dev/null -o $out || + $CC -Wall -Werror -include $header -c -x c /dev/null -o $out || error "cannot compile '$header'" done rm -f $out -- 1.8.3.1