Issue
Currently, I use linux kernel v5.8 on x86.
On my ubuntu machine, /usr/include/x86_64-linux-gnu/asm/unistd_64.h
is old compared to /usr/src/linux-headers-5.8.0-50-generic/arch/x86/include/generated/uapi/asm/unistd_64.h
.
Therefore, I cannot see the new system calls such as openat2
that is added from linux v5.6 in the /usr/include/x86_64-linux-gnu/asm/unistd_64.h
(Ofcourse, I can see such system calls in /usr/src/linux-headers-5.8.0-50-generic/arch/x86/include/generated/uapi/asm/unistd_64.h
.)
I think that /usr/include/x86_64-linux-gnu/asm/unistd_64.h
is same /usr/src/linux-headers-5.4.0-73-generic/arch/x86/include/generated/uapi/asm/unistd_64.h
that is previous kernel version I used.
Why was /usr/include/x86_64-linux-gnu/asm/unistd_64.h
not updated?
Solution
The syscalls provided by your kernel does not have to match the syscalls your C library knows about. The openat2
was added to glibc
by commit e788bea
in April 2020:
Update syscall lists for Linux 5.6.
Linux 5.6 has new openat2 and pidfd_getfd syscalls. This patch adds them to syscall-names.list and regenerates the arch-syscall.h files.
The next glibc
release was 2.32
, in August 2020. In Ubuntu, libc6
packages with version >=2.32
are currently only available for groovy
and hirsute
:
Package libc6
- bionic-updates (libs): GNU C Library: Shared libraries
2.27-3ubuntu1.4: amd64 arm64 armhf i386 ppc64el s390x
also provided by: libc6-udeb- focal-updates (libs): GNU C Library: Shared libraries
2.31-0ubuntu9.2: amd64 arm64 armhf i386 ppc64el s390x
also provided by: libc6-udeb- groovy (20.10) (libs): GNU C Library: Shared libraries
2.32-0ubuntu3: amd64 arm64 armhf i386 ppc64el s390x
also provided by: libc6-udeb- hirsute (21.04) (libs): GNU C Library: Shared libraries
2.33-0ubuntu5: amd64 arm64 armhf i386 ppc64el s390x
But since you would not be getting much portability by requiring glibc>=2.32
and linux-kernel>=5.6
anyway, you could define the syscall numbers in your code (ifndef
) and use syscall(2)
instead.
Answered By - mkayaalp