[PATCH] Loongarch: adapt for the re-introduction of fstat and newfstatat in 6.11
Miao Wang via B4 Relay
devnull+shankerwangmiao.gmail.com@kernel.org
Tue Aug 20 12:27:51 GMT 2024
From: Miao Wang <shankerwangmiao@gmail.com>
In Linux 6.11, fstat and newfstatat are added back. We need to include
this change in kernel-features.h to avoid producing libraries
incompatible with previous linux versions with new headers.
The defination of the two syscalls will be removed when the targeted
kernel version is below 6.11 in loongarch/sysdep.h.
Signed-off-by: Miao Wang <shankerwangmiao@gmail.com>
---
Kernel 6.11 adds back fstat and newfstatat in commit 7697a0fe0154
("LoongArch: Define __ARCH_WANT_NEW_STAT in unistd.h"). With kernel
headers from 6.11, make update-syscall-lists will generate the following
diffs:
diff --git a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
index 8bb82448a7..7e732256fd 100644
--- a/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
+++ b/sysdeps/unix/sysv/linux/loongarch/arch-syscall.h
@@ -59,6 +59,7 @@
#define __NR_fsmount 432
#define __NR_fsopen 430
#define __NR_fspick 433
+#define __NR_fstat 80
#define __NR_fstatfs 44
#define __NR_fsync 82
#define __NR_ftruncate 46
@@ -166,6 +167,7 @@
#define __NR_munmap 215
#define __NR_name_to_handle_at 264
#define __NR_nanosleep 101
+#define __NR_newfstatat 79
#define __NR_nfsservctl 42
#define __NR_open_by_handle_at 265
#define __NR_open_tree 428
With that changed, the compiled libraries will unexpectedly include
calls to these two syscalls, and be incompatible with previous kernel
versions.
This patch addresses this issue by removing the two definations if the
targeted kernel version is below 6.11. I have tested this patch along
with the change to arch-syscall.h with or without the configuration
option --enable-kernel=6.11.
---
.../unix/sysv/linux/loongarch/kernel-features.h | 27 ++++++++++++++++++++++
sysdeps/unix/sysv/linux/loongarch/sysdep.h | 5 ++++
2 files changed, 32 insertions(+)
diff --git a/sysdeps/unix/sysv/linux/loongarch/kernel-features.h b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h
new file mode 100644
index 0000000000..c0e7ccb5de
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h
@@ -0,0 +1,27 @@
+/* Set flags signalling availability of kernel features based on given
+ kernel version number. Loongarch version.
+ Copyright (C) 2024-2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include_next <kernel-features.h>
+
+#define __ASSUME_LOONGARCH_NEWSTAT 1
+
+/* No support for fstat or newfstatat before 6.11. */
+#if __LINUX_KERNEL_VERSION < 0x060b00
+# undef __ASSUME_LOONGARCH_NEWSTAT
+#endif
diff --git a/sysdeps/unix/sysv/linux/loongarch/sysdep.h b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
index eb0ba790da..1fdf18197f 100644
--- a/sysdeps/unix/sysv/linux/loongarch/sysdep.h
+++ b/sysdeps/unix/sysv/linux/loongarch/sysdep.h
@@ -109,6 +109,11 @@
#undef SYS_ify
#define SYS_ify(syscall_name) __NR_##syscall_name
+#ifndef __ASSUME_LOONGARCH_NEWSTAT
+#undef __NR_fstat
+#undef __NR_newfstatat
+#endif
+
#ifndef __ASSEMBLER__
#define VDSO_NAME "LINUX_5.10"
---
base-commit: 2eee835eca960c9d4119279804214b7a1ed5d156
change-id: 20240820-loong-fstat-f57f8be48575
Best regards,
--
Miao Wang <shankerwangmiao@gmail.com>
More information about the Libc-alpha
mailing list