man2: SYNOPSIS: Fix headers, use syscall(), and other fixes
cover man2: SYNOPSIS: Fix headers, use syscall(), and other fixes
Hi Michael,
This is the second set of SYNOPSIS fixes, mostly about fixing the includes, giving reasons why they are being included, and using syscall(SYS_...) when needed. Other minor fixes that I have noticed while doing this are also included in this set.
After this set, about a 60% of man2 will be fixed.
As with the previous patch set, please review thoroughly. I might have overlooked something. It looks good, but it's been a long time...
I must notice that there are a few discrepancies (see the last mails there):
<https://lore.kernel.org/linux-man/[email protected]/T/#u>.
Cheers,
Alex
Alejandro Colomar (39):
futex.2: Use syscall(SYS_...); for system calls without a wrapper getdents.2: Use syscall(SYS_...); for system calls without a wrapper ioctl_tty.2: Fix includes
ioctl_userfaultfd.2: SYNOPSIS: Add <linux/userfaultfd.h> io_destroy.2: Use syscall(SYS_...); for system calls without a wrapper io_getevents.2: Use syscall(SYS_...); for system calls without a
wrapper
ioperm.2: Remove obvious comment
ioprio_set.2: Use syscall(SYS_...); for system calls without a wrapper ipc.2: Use syscall(SYS_...); for system calls without a wrapper ipc.2: Add needed include
kcmp.2: Use syscall(SYS_...); for system calls without a wrapper kcmp.2: tfix
kexec_load.2: Use syscall(SYS_...); for system calls without a wrapper scripts/bash_aliases: man_lsfunc(): Extract syscall name from
syscall(SYS_...)
keyctl.2: Use syscall(SYS_...); for system calls without a glibc
wrapper
link.2: ffix
llseek.2: Use syscall(SYS_...); for system calls without a wrapper lookup_dcookie.2: Use syscall(SYS_...); for system calls without a
wrapper
membarrier.2: Use syscall(SYS_...); for system calls without a wrapper mincore.2: Remove unused include
mknod.2: Remove unused includes
mmap2.2: Use syscall(SYS_...); for system calls without a wrapper modify_ldt.2: Use syscall(SYS_...); for system calls without a wrapper mq_getsetattr.2: Use syscall(SYS_...); for system calls without a
wrapper
alloc_hugepages.2, arch_prctl.2, capget.2, clone.2, delete_module.2,
exit_group.2, get_robust_list.2, getunwind.2, init_module.2: Add note about the use of syscall(2)
open.2: Remove unused <sys/stat.h>
openat2.2: Use syscall(SYS_...); for system calls without a wrapper;
fix includes too
perf_event_open.2: Use syscall(SYS_...); for system calls without a
wrapper
pidfd_getfd.2: Use syscall(SYS_...); for system calls without a
wrapper
pidfd_open.2: Use syscall(SYS_...); for system calls without a wrapper pidfd_send_signal.2: Use syscall(SYS_...); for system calls without a
wrapper. Fix includes too
pipe.2: wfix
pivot_root.2: Use syscall(SYS_...); for system calls without a wrapper poll.2: Remove <signal.h>
process_madvise.2: Use syscall(SYS_...); for system calls without a
wrapper. Fix includes too.
quotactl.2: Better detail why <xfs/xqm.h> is included readdir.2: Use syscall(SYS_...); for system calls without a wrapper readlink.2: ffix
reboot.2: Use syscall(SYS_...); for system calls without a wrapper
man2/alloc_hugepages.2 | 5 +++++ man2/arch_prctl.2 | 6 ++++++ man2/capget.2 | 5 +++++ man2/clone.2 | 6 ++++++ man2/delete_module.2 | 6 ++++++ man2/exit_group.2 | 6 ++++++ man2/futex.2 | 21 +++++++++++---------- man2/get_robust_list.2 | 5 +++++ man2/getdents.2 | 20 +++++++++++++++----- man2/getunwind.2 | 6 ++++++ man2/init_module.2 | 5 +++++ man2/io_destroy.2 | 16 +++++++++------- man2/io_getevents.2 | 21 +++++++++++---------- man2/ioctl_tty.2 | 6 +++--- man2/ioctl_userfaultfd.2 | 1 + man2/ioperm.2 | 2 +- man2/ioprio_set.2 | 15 +++++++++------ man2/ipc.2 | 19 ++++++++++++------- man2/kcmp.2 | 18 ++++++++++-------- man2/kexec_load.2 | 24 +++++++++++++----------- man2/keyctl.2 | 17 +++++++---------- man2/link.2 | 2 +- man2/llseek.2 | 13 +++++++------ man2/lookup_dcookie.2 | 14 +++++++++----- man2/membarrier.2 | 16 ++++++++++------ man2/mincore.2 | 1 - man2/mknod.2 | 2 -- man2/mmap2.2 | 10 ++++++---- man2/modify_ldt.2 | 15 ++++++++++----- man2/mq_getsetattr.2 | 15 ++++++--------- man2/open.2 | 1 - man2/openat2.2 | 20 +++++++++++--------- man2/perf_event_open.2 | 21 +++++++++++---------- man2/pidfd_getfd.2 | 14 +++++++++----- man2/pidfd_open.2 | 13 ++++++++----- man2/pidfd_send_signal.2 | 16 ++++++++++------ man2/pipe.2 | 4 ++-- man2/pivot_root.2 | 14 +++++++++----- man2/poll.2 | 3 +-- man2/process_madvise.2 | 20 ++++++++++++-------- man2/quotactl.2 | 4 +++- man2/readdir.2 | 12 +++++++----- man2/readlink.2 | 2 +- man2/reboot.2 | 12 +++++++----- scripts/bash_aliases | 1 + 45 files changed, 293 insertions(+), 182 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/39 futex.2: Use syscall(SYS_...); for system calls without a wrapper
At the same time, document only headers that are required for calling the function, or those that are specific to the function:
<unistd.h> is required for the syscall() prototype. <sys/syscall.h> is required for the syscall name SYS_xxx. <linux/futex.h> is specific to this syscall.
However, uint32_t is generic enough that it shouldn't be documented here. The system_data_types(7) page already documents it, and is more precise about it. The same goes for timespec.
As a general rule a man[23] page should document the header that includes the prototype, and all of the headers that define macros that should be used with the call. However, the information about types should be restricted to system_data_types(7) (and that page should probably be improved by adding types), except for types that are very specific to the call. Otherwise, we're duplicating info and it's then harder to maintain, and probably outdated in the future.
--- man2/futex.2 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
man2/futex.2 +11 -10
@@ -25,18 +25,22 @@ futex \- fast user-space locking .SH SYNOPSIS .nf .PP -.B #include <linux/futex.h> -.B #include <stdint.h> -.B #include <sys/time.h> +.BR "#include <linux/futex.h>" " /* Definition of " FUTEX_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "long futex(uint32_t *" uaddr ", int " futex_op ", uint32_t " val , -.BI " const struct timespec *" timeout , \ +.BI "long syscall(SYS_futex, uint32_t *" uaddr ", int " futex_op \ +", uint32_t " val , +.BI " const struct timespec *" timeout , \ " \fR /* or: \fBuint32_t \fIval2\fP */" -.BI " uint32_t *" uaddr2 ", uint32_t " val3 ); +.BI " uint32_t *" uaddr2 ", uint32_t " val3 ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR futex (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR futex ()
@@ -1695,9 +1699,6 @@ and a sixth argument was added in Linux 2.6.7. .SH CONFORMING TO This system call is Linux-specific. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.PP Several higher-level programming abstractions are implemented via futexes, including POSIX semaphores and various POSIX threads synchronization mechanisms
Signature · 1 line
2.31.1
PATCH 2/39 getdents.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/getdents.2 | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
man2/getdents.2 +15 -5
@@ -33,19 +33,29 @@ getdents, getdents64 \- get directory entries .SH SYNOPSIS .nf -.BI "long getdents(unsigned int " fd ", struct linux_dirent *" dirp , +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "long syscall(SYS_getdents, unsigned int " fd \ +", struct linux_dirent *" dirp , .BI " unsigned int " count ); .PP -.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" +.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .BR "#include <dirent.h>" .PP .BI "ssize_t getdents64(int " fd ", void *" dirp ", size_t " count ); .fi .PP .IR Note : -There is no glibc wrapper for -.BR getdents (); -see NOTES. +glibc provides no wrapper for +.BR getdents (), +necessitating the use of +.BR syscall (2). +.PP +.IR Note : +There is no definition of +.B struct linux_dirent +in glibc; see NOTES. .SH DESCRIPTION These are not the interfaces you are interested in. Look at
Signature · 1 line
2.31.1
Re: [PATCH 02/39] getdents.2: Use syscall(SYS_...); for system calls without a wrapper
Hi Alex,
See below.
Quoted 30 lines · Alejandro Colomar
Signed-off-by Alejandro Colomar <[email protected]>--- man2/getdents.2 | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)man2/getdents.2 +6
-3@@ -33,19 +33,29 @@ getdents, getdents64 \- get directory entries .SH SYNOPSIS .nf -.BI "long getdents(unsigned int " fd ", struct linux_dirent *" dirp , +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "long syscall(SYS_getdents, unsigned int " fd \ +", struct linux_dirent *" dirp , .BI " unsigned int " count ); .PP -.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" +.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .BR "#include <dirent.h>" .PP .BI "ssize_t getdents64(int " fd ", void *" dirp ", size_t " count ); .fi .PP .IR Note : -There is no glibc wrapper for
man2/getdents.2 line 57
Quoted 10 lines
man2/getdents.2 +8
-2-.BR getdents (); -see NOTES. +glibc provides no wrapper for +.BR getdents (), +necessitating the use of +.BR syscall (2). +.PP +.IR Note : +There is no definition of +.B struct linux_dirent
.I ...
(Fixed)
man2/getdents.2 line 61
Quoted 5 lines
man2/getdents.2 +1
-0+in glibc; see NOTES. .SH DESCRIPTION These are not the interfaces you are interested in. Look at
Cheers,
Michael
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 3/39 ioctl_tty.2: Fix includes
In reply to Alejandro Colomar<sys/ioctl.h> is needed for the prototype of ioctl(). That header also provides most of the constants used by the function. Only a few of those constants are not provided by that header, and need <termios.h>; clarify which constants do need that include.
......
$ <man2/ioctl_tty.2 \
sed -n '/^.SH DESCRIPTION/,/^.SH/p' \
|grep -e '^\.B' -e TIOCM \
|sed 's/^\.B[^ ]* //' \
|awk '{print $1}' \
|grep '^[[:upper:]]' \
|grep -v -e '^CAP' -e '^E' -e '^SIG' -e '^O_' -e '^[TR]XD$' -e '^POLL' \
|sort \
|uniq \
|while read f; do \
find /usr/include/ -type f \
|xargs grep -l "define\s$f" \
|grep -q ioctl.*.h \
||echo $f \
|while read ff; do \
echo "============ $ff"; \
find /usr/include/ -type f \
|xargs grep -n "define\s$ff"; \
done; \
done;
============ CLOCAL
/usr/include/asm-generic/termbits.h:142:#define CLOCAL 0004000
/usr/include/gphoto2/gphoto2-port-portability.h:127:# define CLOCAL 0x00000800
/usr/include/x86_64-linux-gnu/bits/termios-c_cflag.h:34:#define CLOCAL 0004000
============ TCIFLUSH
/usr/include/asm-generic/termbits.h:191:#define TCIFLUSH 0
/usr/include/x86_64-linux-gnu/bits/termios.h:70:#define TCIFLUSH 0
============ TCIOFF
/usr/include/asm-generic/termbits.h:187:#define TCIOFF 2
/usr/include/x86_64-linux-gnu/bits/termios.h:66:#define TCIOFF 2
============ TCIOFLUSH
/usr/include/asm-generic/termbits.h:193:#define TCIOFLUSH 2
/usr/include/x86_64-linux-gnu/bits/termios.h:72:#define TCIOFLUSH 2
============ TCION
/usr/include/asm-generic/termbits.h:188:#define TCION 3
/usr/include/x86_64-linux-gnu/bits/termios.h:67:#define TCION 3
============ TCOFLUSH
/usr/include/asm-generic/termbits.h:192:#define TCOFLUSH 1
/usr/include/x86_64-linux-gnu/bits/termios.h:71:#define TCOFLUSH 1
============ TCOOFF
/usr/include/asm-generic/termbits.h:185:#define TCOOFF 0
/usr/include/x86_64-linux-gnu/bits/termios.h:64:#define TCOOFF 0
============ TCOON
/usr/include/asm-generic/termbits.h:186:#define TCOON 1
/usr/include/x86_64-linux-gnu/bits/termios.h:65:#define TCOON 1
============ TIOCREMOTE
============ TIOCSTART
============ TIOCSTOP
============ TIOCTTYGSTRUCT
============ TIOCUCNTL--- man2/ioctl_tty.2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
man2/ioctl_tty.2 +3 -3
@@ -10,7 +10,9 @@ ioctl_tty \- ioctls for terminals and serial lines .SH SYNOPSIS .nf -.B "#include <termios.h>" +.B #include <sys/ioctl.h> +.BR "#include <termios.h>" " /* Definition of " CLOCAL ", and" +.BR " TC*" { FLUSH , ON , OFF "} constants */" .PP .BI "int ioctl(int " fd ", int " cmd ", ...);" .fi
@@ -119,8 +121,6 @@ Window sizes are kept in the kernel, but not used by the kernel update the window size when the size of the virtual console changes, for example, by loading a new font). .PP -The following constants and structure are defined in -.IR <sys/ioctl.h> . .TP .B TIOCGWINSZ Argument:
Signature · 1 line
2.31.1
PATCH 4/39 ioctl_userfaultfd.2: SYNOPSIS: Add <linux/userfaultfd.h>
In reply to Alejandro Colomar--- man2/ioctl_userfaultfd.2 | 1 + 1 file changed, 1 insertion(+)
man2/ioctl_userfaultfd.2 +1 -0
@@ -31,6 +31,7 @@ ioctl_userfaultfd \- create a file descriptor for handling page faults in user space .SH SYNOPSIS .nf +.BR "#include <linux/userfaultfd.h>" " /* Definition of " UFFD* " constants */" .B #include <sys/ioctl.h> .PP .BI "int ioctl(int " fd ", int " cmd ", ...);"
Signature · 1 line
2.31.1
PATCH 5/39 io_destroy.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro ColomarIn this case there's a wrapper provided by libaio, but this page documents the raw syscall.
--- man2/io_destroy.2 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
man2/io_destroy.2 +9 -7
@@ -9,13 +9,18 @@ io_destroy \- destroy an asynchronous I/O context .SH SYNOPSIS .nf -.BR "#include <linux/aio_abi.h>" " /* Defines needed types */" +.BR "#include <linux/aio_abi.h>" " /* Definition of " aio_context_t " */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int io_destroy(aio_context_t " ctx_id ); +.BI "int syscall(SYS_io_destroy, aio_context_t " ctx_id ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR io_destroy (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .IR Note : this page describes the raw Linux system call interface.
@@ -57,10 +62,7 @@ The asynchronous I/O system calls first appeared in Linux 2.5. is Linux-specific and should not be used in programs that are intended to be portable. .SH NOTES -Glibc does not provide a wrapper for this system call. -You could invoke it using -.BR syscall (2). -But instead, you probably want to use the +You probably want to use the .BR io_destroy () wrapper function provided by .\" http://git.fedorahosted.org/git/?p=libaio.git
Signature · 1 line
2.31.1
PATCH 6/39 io_getevents.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro ColomarIn this case there's a wrapper provided by libaio, but this page documents the raw syscall.
Also remove <linux/time.h> from the includes: 'struct timespec' is already documented in system_data_types(7), where the information is more up to date.
--- man2/io_getevents.2 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
man2/io_getevents.2 +11 -10
@@ -9,16 +9,20 @@ io_getevents \- read asynchronous I/O events from the completion queue .SH SYNOPSIS .nf -.BR "#include <linux/aio_abi.h>" " /* Defines needed types */" -.BR "#include <linux/time.h>" " /* Defines 'struct timespec' */" +.BR "#include <linux/aio_abi.h>" " /* Definition of " *io_* " types */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int io_getevents(aio_context_t " ctx_id ", long " min_nr ", long " nr , -.BI " struct io_event *" events \ -", struct timespec *" timeout ); +.BI "int syscall(SYS_io_getevents, aio_context_t " ctx_id , +.BI " long " min_nr ", long " nr ", struct io_event *" events , +.BI " struct timespec *" timeout ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR io_getevents (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .IR Note : this page describes the raw Linux system call interface.
@@ -94,10 +98,7 @@ The asynchronous I/O system calls first appeared in Linux 2.5. is Linux-specific and should not be used in programs that are intended to be portable. .SH NOTES -Glibc does not provide a wrapper for this system call. -You could invoke it using -.BR syscall (2). -But instead, you probably want to use the +You probably want to use the .BR io_getevents () wrapper function provided by .\" http://git.fedorahosted.org/git/?p=libaio.git
Signature · 1 line
2.31.1
PATCH 7/39 ioperm.2: Remove obvious comment
In reply to Alejandro ColomarOf course that is for the glibc wrapper. As all of the other pages that don't explicitly say otherwise.
--- man2/ioperm.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man2/ioperm.2 +1 -1
@@ -36,7 +36,7 @@ ioperm \- set port input/output permissions .SH SYNOPSIS .nf -.BR "#include <sys/io.h>" " /* for glibc */" +.B #include <sys/io.h> .PP .BI "int ioperm(unsigned long " from ", unsigned long " num ", int " turn_on ); .fi
Signature · 1 line
2.31.1
PATCH 8/39 ioprio_set.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/ioprio_set.2 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
man2/ioprio_set.2 +9 -6
@@ -26,12 +26,18 @@ ioprio_get, ioprio_set \- get/set I/O scheduling class and priority .SH SYNOPSIS .nf -.BI "int ioprio_get(int " which ", int " who ); -.BI "int ioprio_set(int " which ", int " who ", int " ioprio ); +.BR "#include <linux/ioprio.h> " "/* Definition of " IOPRIO_* " constants */" +.BR "#include <sys/syscall.h> " "/* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_ioprio_get, int " which ", int " who ); +.BI "int syscall(SYS_ioprio_set, int " which ", int " who ", int " ioprio ); .fi .PP .IR Note : -There are no glibc wrappers for these system calls; see NOTES. +glibc provides no wrappers for these system calls, +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR ioprio_get ()
@@ -199,9 +205,6 @@ kernel 2.6.13. .SH CONFORMING TO These system calls are Linux-specific. .SH NOTES -Glibc does not provide a wrapper for these system calls; call them using -.BR syscall (2). -.PP Two or more processes or threads can share an I/O context. This will be the case when .BR clone (2)
Signature · 1 line
2.31.1
PATCH 9/39 ipc.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/ipc.2 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
man2/ipc.2 +11 -7
@@ -27,12 +27,20 @@ ipc \- System V IPC system calls .SH SYNOPSIS .nf -.BI "int ipc(unsigned int " call ", int " first ", unsigned long " second , -.BI " unsigned long " third ", void *" ptr ", long " fifth ); +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_ipc, unsigned int " call ", int " first , +.BI " unsigned long " second ", unsigned long " third \ +", void *" ptr , +.BI " long " fifth ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR ipc (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .BR ipc () is a common kernel entry point for the System\ V IPC calls
@@ -56,10 +64,6 @@ system call; instead, .BR semctl (2), .BR shmctl (2), and so on really are implemented as separate system calls. -.PP -Glibc does not provide a wrapper for this system call; -in the unlikely event that you want to call it directly, you can do so using -.BR syscall (2). .SH SEE ALSO .BR msgctl (2), .BR msgget (2),
Signature · 1 line
2.31.1
PATCH 10/39 ipc.2: Add needed include
In reply to Alejandro ColomarThe constants needed for using this function are defined in <linux/ipc.h>. Add the include, even when those constants are not mentioned in this manual page.
--- man2/ipc.2 | 1 + 1 file changed, 1 insertion(+)
man2/ipc.2 +1 -0
@@ -27,6 +27,7 @@ ipc \- System V IPC system calls .SH SYNOPSIS .nf +.BR "#include <linux/ipc.h>" " /* Definition of needed constants */" .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" .B #include <unistd.h> .PP
Signature · 1 line
2.31.1
PATCH 11/39 kcmp.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/kcmp.2 | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
man2/kcmp.2 +9 -7
@@ -30,14 +30,19 @@ kcmp \- compare two processes to determine if they share a kernel resource .SH SYNOPSIS .nf -.B #include <linux/kcmp.h> +.BR "#include <linux/kcmp.h>" " /* Definition of " KCMP_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int kcmp(pid_t " pid1 ", pid_t " pid2 ", int " type , -.BI " unsigned long " idx1 ", unsigned long " idx2 ); +.BI "int syscall(SYS_kcmp, pid_t " pid1 ", pid_t " pid2 ", int " type , +.BI " unsigned long " idx1 ", unsigned long " idx2 ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR kcmp (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR kcmp ()
@@ -303,9 +308,6 @@ system call first appeared in Linux 3.5. .BR kcmp () is Linux-specific and should not be used in programs intended to be portable. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.PP Before Linux 5.12, this system call is available only if the kernel is configured with .BR CONFIG_CHECKPOINT_RESTORE ,
Signature · 1 line
2.31.1
PATCH 12/39 kcmp.2: tfix
In reply to Alejandro Colomar--- man2/kcmp.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man2/kcmp.2 +1 -1
@@ -311,7 +311,7 @@ is Linux-specific and should not be used in programs intended to be portable. Before Linux 5.12, this system call is available only if the kernel is configured with .BR CONFIG_CHECKPOINT_RESTORE , -since the original pupose the system call was for the +since the original purpose of the system call was for the checkpoint/restore in user space (CRIU) feature. (The alternative to this system call would have been to expose suitable process information via the
Signature · 1 line
2.31.1
PATCH 13/39 kexec_load.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/kexec_load.2 | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
man2/kexec_load.2 +13 -11
@@ -29,18 +29,23 @@ kexec_load, kexec_file_load \- load a new kernel for later execution .SH SYNOPSIS .nf -.B #include <linux/kexec.h> +.BR "#include <linux/kexec.h>" " /* Definition of " KEXEC_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "long kexec_load(unsigned long " entry ", unsigned long " nr_segments , -.BI " struct kexec_segment *" segments , -.BI " unsigned long " flags ); -.BI "long kexec_file_load(int " kernel_fd ", int " initrd_fd , -.BI " unsigned long " cmdline_len ", const char *" cmdline , -.BI " unsigned long " flags ); +.BI "long syscall(SYS_kexec_load, unsigned long " entry , +.BI " unsigned long " nr_segments \ +", struct kexec_segment *" segments , +.BI " unsigned long " flags ); +.BI "long syscall(SYS_kexec_file_load, int " kernel_fd ", int " initrd_fd , +.BI " unsigned long " cmdline_len ", const char *" cmdline , +.BI " unsigned long " flags ); .fi .PP .IR Note : -There are no glibc wrappers for these system calls; see NOTES. +glibc provides no wrappers for these system calls, +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR kexec_load ()
@@ -332,9 +337,6 @@ The system call first appeared in Linux 3.17. .SH CONFORMING TO These system calls are Linux-specific. -.SH NOTES -Glibc does not provide a wrapper for these system calls; call them using -.BR syscall (2). .SH SEE ALSO .BR reboot (2), .BR syscall (2),
Signature · 1 line
2.31.1
PATCH 14/39 scripts/bash_aliases: man_lsfunc(): Extract syscall name from syscall(SYS_...)
In reply to Alejandro Colomar--- scripts/bash_aliases | 1 + 1 file changed, 1 insertion(+)
scripts/bash_aliases +1 -0
@@ -136,6 +136,7 @@ function man_lsfunc() |sed_rm_ccomments \ |pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \ |grep '^[0-9]' \ + |sed 's/syscall(SYS_\(\w*\),/\1(/' \ |sed -E 's/^[^(]+ \**(\w+)\(.*/\1/' \ |uniq; }
Signature · 1 line
2.31.1
PATCH 15/39 keyctl.2: Use syscall(SYS_...); for system calls without a glibc wrapper
In reply to Alejandro ColomarRemove the libkeyutils prototype from the synopsis, which isn't documented in the rest of the page, and as NOTES says, it's probably better to use the various library functions.
--- man2/keyctl.2 | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
man2/keyctl.2 +7 -10
@@ -30,22 +30,20 @@ keyctl \- manipulate the kernel's key management facility .SH SYNOPSIS .nf -.B #include <keyutils.h> -.PP -.BI "long keyctl(int " operation ", ...);" -.PP -.B "/* For direct call via syscall(2): */" -.B #include <asm/unistd.h> -.B #include <linux/keyctl.h> +.BR "#include <linux/keyctl.h>" " /* Definition of " KEY* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" .B #include <unistd.h> .PP -.BI "long syscall(__NR_keyctl, int " operation ", unsigned long " arg2 , +.BI "long syscall(SYS_keyctl, int " operation ", unsigned long " arg2 , .BI " unsigned long " arg3 ", unsigned long " arg4 , .BI " unsigned long " arg5 ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR keyctl (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .BR keyctl () allows user-space programs to perform key manipulation.
@@ -1954,7 +1952,6 @@ This system call first appeared in Linux 2.6.10. .SH CONFORMING TO This system call is a nonstandard Linux extension. .SH NOTES -Glibc does not provide a wrapper for this system call. A wrapper is provided in the .IR libkeyutils library.
Signature · 1 line
2.31.1
PATCH 16/39 link.2: ffix
In reply to Alejandro Colomar--- man2/link.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man2/link.2 +1 -1
@@ -38,7 +38,7 @@ link, linkat \- make a new name for a file .PP .BI "int link(const char *" oldpath ", const char *" newpath ); .PP -.BR "#include <fcntl.h> " "/* Definition of AT_* constants */" +.BR "#include <fcntl.h> " "/* Definition of " AT_* " constants */" .B #include <unistd.h> .PP .BI "int linkat(int " olddirfd ", const char *" oldpath ,
Signature · 1 line
2.31.1
PATCH 17/39 llseek.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/llseek.2 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
man2/llseek.2 +7 -6
@@ -31,15 +31,19 @@ _llseek \- reposition read/write file offset .SH SYNOPSIS .nf +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" .B #include <unistd.h> .PP -.BI "int _llseek(unsigned int " fd ", unsigned long " offset_high , +.BI "int syscall(SYS__llseek, unsigned int " fd ", unsigned long " offset_high , .BI " unsigned long " offset_low ", loff_t *" result , .BI " unsigned int " whence ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR _llseek (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION Note: for information about the .BR llseek (3)
@@ -97,10 +101,7 @@ is invalid. This function is Linux-specific, and should not be used in programs intended to be portable. .SH NOTES -Glibc does not provide a wrapper for this system call. -To invoke it directly, use -.BR syscall (2). -However, you probably want to use the +You probably want to use the .BR lseek (2) wrapper function instead. .SH SEE ALSO
Signature · 1 line
2.31.1
PATCH 18/39 lookup_dcookie.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/lookup_dcookie.2 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
man2/lookup_dcookie.2 +9 -5
@@ -29,11 +29,18 @@ lookup_dcookie \- return a directory entry's path .SH SYNOPSIS .nf -.BI "int lookup_dcookie(uint64_t " cookie ", char *" buffer ", size_t " len ); +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_lookup_dcookie, uint64_t " cookie ", char *" buffer , +.BI " size_t " len ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR lookup_dcookie (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION Look up the full path of the directory entry specified by the value .IR cookie .
@@ -92,8 +99,5 @@ It relies on a kernel driver to register cookies for directory entries. .PP The path returned may be suffixed by the string " (deleted)" if the directory entry has been removed. -.PP -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). .SH SEE ALSO .BR oprofile (1)
Signature · 1 line
2.31.1
PATCH 19/39 membarrier.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/membarrier.2 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
man2/membarrier.2 +10 -6
@@ -28,13 +28,20 @@ membarrier \- issue memory barriers on a set of threads .SH SYNOPSIS .nf .PP -.B #include <linux/membarrier.h> +.BR "#include <linux/membarrier.h>" \ +" /* Definition of " MEMBARRIER_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int membarrier(int " cmd ", unsigned int " flags ", int " cpu_id ); +.BI "int syscall(SYS_membarrier, int " cmd ", unsigned int " flags \ +", int " cpu_id ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR membarrier (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR membarrier ()
@@ -322,9 +329,6 @@ Examples where .BR membarrier () can be useful include implementations of Read-Copy-Update libraries and garbage collectors. -.PP -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). .SH EXAMPLES Assuming a multithreaded application where "fast_path()" is executed very frequently, and where "slow_path()" is executed infrequently, the
Signature · 1 line
2.31.1
PATCH 20/39 mincore.2: Remove unused include
In reply to Alejandro ColomarAFAICS, there's no use for <unistd.h> here. The prototype is declared in <sys/mman.h>, and there are no constants needed.
--- man2/mincore.2 | 1 - 1 file changed, 1 deletion(-)
man2/mincore.2 +0 -1
@@ -36,7 +36,6 @@ mincore \- determine whether pages are resident in memory .SH SYNOPSIS .nf -.B #include <unistd.h> .B #include <sys/mman.h> .PP .BI "int mincore(void *" addr ", size_t " length ", unsigned char *" vec );
Signature · 1 line
2.31.1
PATCH 21/39 mknod.2: Remove unused includes
In reply to Alejandro ColomarAll of the constants used by mknod() are dfined in <sys/stat.h>.
--- man2/mknod.2 | 2 -- 1 file changed, 2 deletions(-)
man2/mknod.2 +0 -2
@@ -18,8 +18,6 @@ mknod, mknodat \- create a special or ordinary file .SH SYNOPSIS .nf .B #include <sys/stat.h> -.B #include <fcntl.h> -.B #include <unistd.h> .PP .BI "int mknod(const char *" pathname ", mode_t " mode ", dev_t " dev ); .PP
Signature · 1 line
2.31.1
PATCH 22/39 mmap2.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/mmap2.2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
man2/mmap2.2 +6 -4
@@ -31,11 +31,13 @@ mmap2 \- map files or devices into memory .SH SYNOPSIS .nf -.B #include <sys/mman.h> +.BR "#include <sys/mman.h>" " /* Definition of " MAP_* " and " PROT_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.BR "#include <unistd.h> .PP -.BI "void *mmap2(unsigned long " addr ", unsigned long " length , -.BI " unsigned long " prot ", unsigned long " flags , -.BI " unsigned long " fd ", unsigned long " pgoffset ); +.BI "void *syscall(SYS_mmap2, unsigned long " addr ", unsigned long " length , +.BI " unsigned long " prot ", unsigned long " flags , +.BI " unsigned long " fd ", unsigned long " pgoffset ); .fi .SH DESCRIPTION This is probably not the system call that you are interested in; instead, see
Signature · 1 line
2.31.1
PATCH 23/39 modify_ldt.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/modify_ldt.2 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
man2/modify_ldt.2 +10 -5
@@ -27,11 +27,19 @@ modify_ldt \- get or set a per-process LDT entry .SH SYNOPSIS .nf -.BI "int modify_ldt(int " func ", void *" ptr ", unsigned long " bytecount ); +.BR "#include <asm/ldt.h>" " /* Definition of " "struct user_desc" " */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_modify_ldt, int " func ", void *" ptr , +.BI " unsigned long " bytecount ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR modify_ldt (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .BR modify_ldt () reads or writes the local descriptor table (LDT) for a process.
@@ -168,9 +176,6 @@ is neither 0, 1, 2, nor 0x11. This call is Linux-specific and should not be used in programs intended to be portable. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.PP .BR modify_ldt () should not be used for thread-local storage, as it slows down context switches and only supports a limited number of threads.
Signature · 1 line
2.31.1
PATCH 24/39 mq_getsetattr.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/mq_getsetattr.2 | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
man2/mq_getsetattr.2 +6 -9
@@ -27,14 +27,13 @@ mq_getsetattr \- get/set message queue attributes .SH SYNOPSIS .nf -.B #include <mqueue.h> +.BR "#include <mqueue.h>" " /* Definition of " "struct mq_attr" " */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int mq_getsetattr(mqd_t " mqdes ", const struct mq_attr *" newattr , -.BI " struct mq_attr *" oldattr ); +.BI "int syscall(SYS_mq_getsetattr, mqd_t " mqdes , +.BI " const struct mq_attr *" newattr ", struct mq_attr *" oldattr ); .fi -.PP -.IR Note : -There is no glibc wrapper for this system call; see NOTES. .SH DESCRIPTION Do not use this system call. .PP
@@ -48,9 +47,7 @@ see the description of .SH CONFORMING TO This interface is nonstandard; avoid its use. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -(Actually, never call it unless you are writing a C library!) +Never call it unless you are writing a C library! .SH SEE ALSO .BR mq_getattr (3), .BR mq_overview (7)
Signature · 1 line
2.31.1
PATCH 25/39 alloc_hugepages.2, arch_prctl.2, capget.2, clone.2, delete_module.2, exit_group.2, get_robust_list.2, getunwind.2, init_module.2: Add note about the use of syscall(2)
In reply to Alejandro Colomar--- man2/alloc_hugepages.2 | 5 +++++ man2/arch_prctl.2 | 6 ++++++ man2/capget.2 | 5 +++++ man2/clone.2 | 6 ++++++ man2/delete_module.2 | 6 ++++++ man2/exit_group.2 | 6 ++++++ man2/get_robust_list.2 | 5 +++++ man2/getunwind.2 | 6 ++++++ man2/init_module.2 | 5 +++++ 9 files changed, 50 insertions(+)
man2/alloc_hugepages.2 +5 -0
@@ -35,6 +35,11 @@ alloc_hugepages, free_hugepages \- allocate or free huge pages .BI "int syscall(SYS_free_hugepages, void *" addr ); .\" asmlinkage int sys_free_hugepages(unsigned long addr); .fi +.PP +.IR Note : +glibc provides no wrappers for these system calls, +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The system calls .BR alloc_hugepages ()
man2/arch_prctl.2 +6 -0
@@ -34,6 +34,12 @@ arch_prctl \- set architecture-specific thread state .BI "int syscall(SYS_arch_prctl, int " code ", unsigned long " addr ); .BI "int syscall(SYS_arch_prctl, int " code ", unsigned long *" addr ); .fi +.PP +.IR Note : +glibc provides no wrapper for +.BR arch_prctl (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .BR arch_prctl () sets architecture-specific process or thread state.
man2/capget.2 +5 -0
@@ -28,6 +28,11 @@ capget, capset \- set/get capabilities of thread(s) .BI "int syscall(SYS_capset, cap_user_header_t " hdrp , .BI " const cap_user_data_t " datap ); .fi +.PP +.IR Note : +glibc provides no wrappers for these system calls, +necessitating the use of +.BR syscall (2). .SH DESCRIPTION These two system calls are the raw kernel interface for getting and setting thread capabilities.
man2/clone.2 +6 -0
@@ -63,6 +63,12 @@ clone, __clone2, clone3 \- create a child process .PP .BI "long syscall(SYS_clone3, struct clone_args *" cl_args ", size_t " size ); .fi +.PP +.IR Note : +glibc provides no wrapper for +.BR clone3 (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION These system calls create a new ("child") process, in a manner similar to
man2/delete_module.2 +6 -0
@@ -33,6 +33,12 @@ delete_module \- unload a kernel module .PP .BI "int syscall(SYS_delete_module, const char *" name ", unsigned int " flags ); .fi +.PP +.IR Note : +glibc provides no wrapper for +.BR delete_module (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR delete_module ()
man2/exit_group.2 +6 -0
@@ -32,6 +32,12 @@ exit_group \- exit all threads in a process .PP .BI "noreturn void syscall(SYS_exit_group, int " status ); .fi +.PP +.IR Note : +glibc provides no wrapper for +.BR exit_group (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION This system call is equivalent to .BR _exit (2)
man2/get_robust_list.2 +5 -0
@@ -42,6 +42,11 @@ get_robust_list, set_robust_list \- get/set list of robust futexes .BI "long syscall(SYS_set_robust_list," .BI " struct robust_list_head *" head ", size_t " len ); .fi +.PP +.IR Note : +glibc provides no wrappers for these system calls, +necessitating the use of +.BR syscall (2). .SH DESCRIPTION These system calls deal with per-thread robust futex lists. These lists are managed in user space:
man2/getunwind.2 +6 -0
@@ -35,6 +35,12 @@ getunwind \- copy the unwind data to caller's buffer .PP .BI "long syscall(SYS_getunwind, void " *buf ", size_t " buf_size ); .fi +.PP +.IR Note : +glibc provides no wrapper for +.BR getunwind (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .I Note: this system call is obsolete. .PP
man2/init_module.2 +5 -0
@@ -38,6 +38,11 @@ init_module, finit_module \- load a kernel module .BI "int syscall(SYS_finit_module, int " fd ", const char *" param_values , .BI " int " flags ); .fi +.PP +.IR Note : +glibc provides no wrappers for these system calls, +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .BR init_module () loads an ELF image into kernel space,
Signature · 1 line
2.31.1
PATCH 26/39 open.2: Remove unused <sys/stat.h>
In reply to Alejandro ColomarI can't see a reason to include it. <fcntl.h> provides O_* constants for 'flags', S_* constants for 'mode', and mode_t.
Probably a long time ago, some of those weren't defined in <fcntl.h>, and both headers needed to be included, or maybe it's a historical error.
--- man2/open.2 | 1 - 1 file changed, 1 deletion(-)
man2/open.2 +0 -1
@@ -53,7 +53,6 @@ open, openat, creat \- open and possibly create a file .SH SYNOPSIS .nf -.B #include <sys/stat.h> .B #include <fcntl.h> .PP .BI "int open(const char *" pathname ", int " flags );
Signature · 1 line
2.31.1
Re: [PATCH 26/39] open.2: Remove unused <sys/stat.h>
Quoted 8 lines · Alejandro Colomar
I can't see a reason to include it. <
fcntl.h> provides O_* constants for 'flags', S_* constants for 'mode', andmode_t.Probably a long time ago, some of those weren't defined in <
fcntl.h>, and both headers needed to be included, or maybe it's a historical error.Signed-off-by Alejandro Colomar <[email protected]>
Drop this one, please. (We discussed it yesterday.)
Quoted 17 lines
--- man2/open.2 | 1 - 1 file changed, 1 deletion(-)man2/open.2 +0
-1@@ -53,7 +53,6 @@ open, openat, creat \- open and possibly create a file .SH SYNOPSIS .nf -.B #include <sys/stat.h> .B #include <fcntl.h> .PP .BI "int open(const char *" pathname ", int " flags );
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/
Re: [PATCH 26/39] open.2: Remove unused <sys/stat.h>
Quoted 11 lines · Alejandro Colomar (man-pages)
Quoted 8 lines · Alejandro Colomar
I can't see a reason to include it. <
fcntl.h> provides O_* constants for 'flags', S_* constants for 'mode', andmode_t.Probably a long time ago, some of those weren't defined in <
fcntl.h>, and both headers needed to be included, or maybe it's a historical error.Signed-off-by Alejandro Colomar <[email protected]>Drop this one, please. (We discussed it yesterday.)
Okay.
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 27/39 openat2.2: Use syscall(SYS_...); for system calls without a wrapper; fix includes too
In reply to Alejandro Colomar--- man2/openat2.2 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
man2/openat2.2 +11 -9
@@ -26,16 +26,21 @@ openat2 \- open and possibly create a file (extended) .SH SYNOPSIS .nf -.B #include <sys/stat.h> -.B #include <fcntl.h> -.B #include <linux/openat2.h> +.BR "#include <fcntl.h>" \ +" /* Definition of " O_* " and " S_* " constants */" +.BR "#include <linux/openat2.h>" " /* Definition of " RESOLVE_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "long openat2(int " dirfd ", const char *" pathname , -.BI " struct open_how *" how ", size_t " size ); +.BI "long syscall(SYS_openat2, int " dirfd ", const char *" pathname , +.BI " struct open_how *" how ", size_t " size ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR openat2 (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR openat2 ()
@@ -494,9 +499,6 @@ The semantics of were modeled after FreeBSD's .BR O_BENEATH . .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.\" .SS Extensibility In order to allow for future extensibility, .BR openat2 ()
Signature · 1 line
2.31.1
PATCH 28/39 perf_event_open.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/perf_event_open.2 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
man2/perf_event_open.2 +11 -10
@@ -29,16 +29,21 @@ perf_event_open \- set up performance monitoring .SH SYNOPSIS .nf -.B #include <linux/perf_event.h> -.B #include <linux/hw_breakpoint.h> +.BR "#include <linux/perf_event.h>" " /* Definition of " PERF_* " constants */" +.BR "#include <linux/hw_breakpoint.h>" " /* Definition of " HW_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int perf_event_open(struct perf_event_attr *" attr , -.BI " pid_t " pid ", int " cpu ", int " group_fd , -.BI " unsigned long " flags ); +.BI "int syscall(SYS_perf_event_open, struct perf_event_attr *" attr , +.BI " pid_t " pid ", int " cpu ", int " group_fd \ +", unsigned long " flags ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR perf_event_open (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION Given a list of parameters, .BR perf_event_open ()
@@ -3641,10 +3646,6 @@ This system call Linux-specific and should not be used in programs intended to be portable. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -See the example below. -.PP The official way of knowing if .BR perf_event_open () support is enabled is checking
Signature · 1 line
2.31.1
PATCH 29/39 pidfd_getfd.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/pidfd_getfd.2 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
man2/pidfd_getfd.2 +9 -5
@@ -27,11 +27,18 @@ pidfd_getfd \- obtain a duplicate of another process's file descriptor .SH SYNOPSIS .nf -.BI "int pidfd_getfd(int " pidfd ", int " targetfd ", unsigned int " flags ); +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_pidfd_getfd, int " pidfd ", int " targetfd , +.BI " unsigned int " flags ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR pidfd_getfd (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR pidfd_getfd ()
@@ -121,9 +128,6 @@ first appeared in Linux 5.6. .BR pidfd_getfd () is Linux specific. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.PP For a description of PID file descriptors, see .BR pidfd_open (2). .PP
Signature · 1 line
2.31.1
PATCH 30/39 pidfd_open.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/pidfd_open.2 | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
man2/pidfd_open.2 +8 -5
@@ -27,11 +27,17 @@ pidfd_open \- obtain a file descriptor that refers to a process .SH SYNOPSIS .nf -.BI "int pidfd_open(pid_t " pid ", unsigned int " flags ); +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_pidfd_open, pid_t " pid ", unsigned int " flags ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR pidfd_open (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR pidfd_open ()
@@ -89,9 +95,6 @@ first appeared in Linux 5.3. .BR pidfd_open () is Linux specific. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.PP The following code sequence can be used to obtain a file descriptor for the child of .BR fork (2):
Signature · 1 line
2.31.1
PATCH 31/39 pidfd_send_signal.2: Use syscall(SYS_...); for system calls without a wrapper. Fix includes too
In reply to Alejandro Colomar--- man2/pidfd_send_signal.2 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
man2/pidfd_send_signal.2 +10 -6
@@ -27,14 +27,21 @@ pidfd_send_signal \- send a signal to a process specified by a file descriptor .SH SYNOPSIS .nf -.B "#include <signal.h>" +.BR "#include <linux/signal.h>" " /* Definition of " SIG* " constants */" +.BR "#include <signal.h>" " /* Definition of " SI_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int pidfd_send_signal(int " pidfd ", int " sig ", siginfo_t *" info , +.BI "int syscall(SYS_pidfd_send_signal, int " pidfd ", int " sig \ +", siginfo_t *" info , .BI " unsigned int " flags ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR pidfd_send_signal (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION The .BR pidfd_send_signal ()
@@ -136,9 +143,6 @@ first appeared in Linux 5.1. .BR pidfd_send_signal () is Linux specific. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.\" .SS PID file descriptors The .I pidfd
Signature · 1 line
2.31.1
PATCH 32/39 pipe.2: wfix
In reply to Alejandro ColomarFor consistency with other pages.
--- man2/pipe.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man2/pipe.2 +2 -2
@@ -40,10 +40,10 @@ pipe, pipe2 \- create pipe .nf .B #include <unistd.h> .PP -.BI "int pipe(int " pipefd "[2]);" +.BI "int pipe(int " pipefd [2]); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" -.BR "#include <fcntl.h>" " /* Obtain O_* constant definitions */" +.BR "#include <fcntl.h>" " /* Definition of " O_* " constants */" .B #include <unistd.h> .PP .BI "int pipe2(int " pipefd "[2], int " flags );
Signature · 1 line
2.31.1
PATCH 33/39 pivot_root.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/pivot_root.2 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
man2/pivot_root.2 +9 -5
@@ -29,11 +29,18 @@ pivot_root \- change the root mount .SH SYNOPSIS .nf -.BI "int pivot_root(const char *" new_root ", const char *" put_old ); +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> +.PP +.BI "int syscall(SYS_pivot_root, const char *" new_root \ +", const char *" put_old ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR pivot_root (), +necessitating the use of +.BR syscall (2). .SH DESCRIPTION .BR pivot_root () changes the root mount in the mount namespace of the calling process.
@@ -168,9 +175,6 @@ was introduced in Linux 2.3.41. .BR pivot_root () is Linux-specific and hence is not portable. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). -.PP A command-line interface for this system call is provided by .BR pivot_root (8). .PP
Signature · 1 line
2.31.1
PATCH 34/39 poll.2: Remove <signal.h>
In reply to Alejandro ColomarIt is only used for providing 'sigset_t'. We're only documenting (with some exceptions) the includes needed for constants and the prototype itself. And 'sigset_t' is better documented in system_data_types(7). Remove that include.
--- man2/poll.2 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
man2/poll.2 +1 -2
@@ -37,11 +37,10 @@ poll, ppoll \- wait for some event on a file descriptor .BI "int poll(struct pollfd *" fds ", nfds_t " nfds ", int " timeout ); .PP .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" -.B #include <signal.h> .B #include <poll.h> .PP .BI "int ppoll(struct pollfd *" fds ", nfds_t " nfds , -.BI " const struct timespec *" tmo_p ", const sigset_t *" sigmask ); +.BI " const struct timespec *" tmo_p ", const sigset_t *" sigmask ); .fi .SH DESCRIPTION .BR poll ()
Signature · 1 line
2.31.1
PATCH 35/39 process_madvise.2: Use syscall(SYS_...); for system calls without a wrapper. Fix includes too.
In reply to Alejandro Colomar--- man2/process_madvise.2 | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
man2/process_madvise.2 +12 -8
@@ -30,15 +30,22 @@ process_madvise \- give advice about use of memory to a process .SH SYNOPSIS .nf -.B #include <sys/uio.h> +.BR "#include <sys/mman.h>" " /* Definition of " MADV_* " constants */" +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.BR "#include <sys/uio.h>" " /* Definition of " "struct iovec" " type */" +.B #include <unistd.h> .PP -.BI "ssize_t process_madvise(int " pidfd ", const struct iovec *" iovec , -.BI " size_t " vlen ", int " advice , -.BI " unsigned int " flags ");" +.BI "ssize_t syscall(SYS_process_madvise, int " pidfd , +.BI " const struct iovec *" iovec ", size_t " vlen \ +", int " advice , +.BI " unsigned int " flags ");" .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +glibc provides no wrapper for +.BR process_madvise (), +necessitating the use of +.BR syscall (2). .\" FIXME: See <https://sourceware.org/bugzilla/show_bug.cgi?id=27380> .SH DESCRIPTION The
@@ -205,9 +212,6 @@ configuration option. The .BR process_madvise () system call is Linux-specific. -.SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). .SH SEE ALSO .BR madvise (2), .BR pidfd_open (2),
Signature · 1 line
2.31.1
PATCH 36/39 quotactl.2: Better detail why <xfs/xqm.h> is included
In reply to Alejandro Colomar--- man2/quotactl.2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
man2/quotactl.2 +3 -1
@@ -30,7 +30,9 @@ quotactl \- manipulate disk quotas .SH SYNOPSIS .nf .B #include <sys/quota.h> -.B #include <xfs/xqm.h> /* for XFS quotas */ +.BR "#include <xfs/xqm.h>" " /* Definition of " Q_X* " and " XFS_QUOTA_* \ +" constants" +.RB " (or " <linux/dqblk_xfs.h> "; see NOTES) */" .PP .BI "int quotactl(int " cmd ", const char *" special ", int " id \ ", caddr_t " addr );
Signature · 1 line
2.31.1
PATCH 37/39 readdir.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro Colomar--- man2/readdir.2 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
man2/readdir.2 +7 -5
@@ -32,13 +32,17 @@ readdir \- read directory entry .SH SYNOPSIS .nf +.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" +.B #include <unistd.h> .PP -.BI "int readdir(unsigned int " fd ", struct old_linux_dirent *" dirp "," -.BI " unsigned int " count ); +.BI "int syscall(SYS_readdir, unsigned int " fd , +.BI " struct old_linux_dirent *" dirp ", unsigned int " count ); .fi .PP .IR Note : -There is no glibc wrapper for this system call; see NOTES. +There is no definition of +.BR "struct old_linux_dirent" ; +see NOTES. .SH DESCRIPTION This is not the function you are interested in. Look at
@@ -116,8 +120,6 @@ File descriptor does not refer to a directory. .SH CONFORMING TO This system call is Linux-specific. .SH NOTES -Glibc does not provide a wrapper for this system call; call it using -.BR syscall (2). You will need to define the .I old_linux_dirent structure yourself.
Signature · 1 line
2.31.1
PATCH 38/39 readlink.2: ffix
In reply to Alejandro Colomar--- man2/readlink.2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man2/readlink.2 +1 -1
@@ -51,7 +51,7 @@ readlink, readlinkat \- read value of a symbolic link .BI "ssize_t readlink(const char *restrict " pathname ", char *restrict " buf , .BI " size_t " bufsiz ); .PP -.BR "#include <fcntl.h> " "/* Definition of AT_* constants */" +.BR "#include <fcntl.h> " "/* Definition of " AT_* " constants */" .B #include <unistd.h> .PP .BI "ssize_t readlinkat(int " dirfd ", const char *restrict " pathname ,
Signature · 1 line
2.31.1
PATCH 39/39 reboot.2: Use syscall(SYS_...); for system calls without a wrapper
In reply to Alejandro ColomarExplain also why are headers needed.
And some ffix.
--- man2/reboot.2 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
man2/reboot.2 +7 -5
@@ -30,21 +30,23 @@ reboot \- reboot or enable/disable Ctrl-Alt-Del .SH SYNOPSIS .nf -/* Since kernel version 2.1.30 there are symbolic names LINUX_REBOOT_* +.RB "/* Since kernel version 2.1.30 there are symbolic names " LINUX_REBOOT_* for the constants and a fourth argument to the call: */ .PP +.BR "#include <linux/reboot.h> " \ +"/* Definition of " LINUX_REBOOT_* " constants */" +.BR "#include <sys/syscall.h> " "/* Definition of " SYS_* " constants */" .B #include <unistd.h> -.B #include <linux/reboot.h> .PP -.BI "int reboot(int " magic ", int " magic2 ", int " cmd ", void *" arg ); +.BI "int syscall(SYS_reboot, int " magic ", int " magic2 ", int " cmd ", void *" arg ); .PP /* Under glibc and most alternative libc's (including uclibc, dietlibc, musl and a few others), some of the constants involved have gotten - symbolic names RB_*, and the library call is a 1-argument +.RB " symbolic names " RB_* ", and the library call is a 1-argument" wrapper around the system call: */ .PP +.BR "#include <sys/reboot.h> " "/* Definition of " RB_* " constants */" .B #include <unistd.h> -.B #include <sys/reboot.h> .PP .BI "int reboot(int " cmd ); .fi
Signature · 1 line
2.31.1
Re: [PATCH 39/39] reboot.2: Use syscall(SYS_...); for system calls without a wrapper
Quoted 1 line · Alejandro Colomar
Explain also why are headers needed.
s/are headers/headers are/
Quoted 3 lines
And some ffix.
Signed-off-by Alejandro Colomar <[email protected]>
Signature · 3 lines
Alejandro Colomar Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/ http://www.alejandro-colomar.es/
Re: [PATCH 39/39] reboot.2: Use syscall(SYS_...); for system calls without a wrapper
Quoted 4 lines · Alejandro Colomar (man-pages)
Quoted 1 line · Alejandro Colomar
Explain also why are headers needed.
s/are headers/headers are/
Done.
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
Hello Alex,
Quoted 8 lines · Alejandro Colomar
Hi Michael,
This is the second set of SYNOPSIS fixes, mostly about fixing the includes, giving reasons why they are being included, and using
syscall(SYS_...)when needed. Other minor fixes that I have noticed while doing this are also included in this set.
Quoted 4 lines
After this set, about a 60% of man2 will be fixed.
As with the previous patch set, please review thoroughly. I might have overlooked something. It looks good, but it's been a long time...
Things looked okay to me. I dropped the patch you asked me to drop, and made a formatting after the getdents.2 patch
Quoted 2 lines
I must notice that there are a few discrepancies (see the last mails there):
<https://lore.kernel.org/linux-man/[email protected]/T/#u>.
Yep. I real the discussion. I think I'm okay with your choice.
I've applied all of the patches.
Thanks,
Michael
Quoted 100 lines
Alejandro Colomar (39):
futex.2: Usesyscall(SYS_...); for system calls without a wrapper getdents.2: Usesyscall(SYS_...); for system calls without a wrapper ioctl_tty.2: Fix includes
ioctl_userfaultfd.2: SYNOPSIS: Add <linux/userfaultfd.h> io_destroy.2: Usesyscall(SYS_...); for system calls without a wrapper io_getevents.2: Usesyscall(SYS_...); for system calls without a
wrapper
ioperm.2: Remove obvious comment
ioprio_set.2: Usesyscall(SYS_...); for system calls without a wrapper ipc.2: Usesyscall(SYS_...); for system calls without a wrapper ipc.2: Add needed include
kcmp.2: Usesyscall(SYS_...); for system calls without a wrapper kcmp.2: tfix
kexec_load.2: Usesyscall(SYS_...); for system calls without a wrapperscripts/bash_aliases:man_lsfunc(): Extract syscall name fromsyscall(SYS_...)keyctl.2: Use
syscall(SYS_...); for system calls without a glibc
wrapper
link.2: ffix
llseek.2: Usesyscall(SYS_...); for system calls without a wrapper lookup_dcookie.2: Usesyscall(SYS_...); for system calls without a
wrapper
membarrier.2: Usesyscall(SYS_...); for system calls without a wrapper mincore.2: Remove unused include
mknod.2: Remove unused includes
mmap2.2: Usesyscall(SYS_...); for system calls without a wrapper modify_ldt.2: Usesyscall(SYS_...); for system calls without a wrapper mq_getsetattr.2: Usesyscall(SYS_...); for system calls without a
wrapper
alloc_hugepages.2, arch_prctl.2, capget.2, clone.2, delete_module.2,
exit_group.2, get_robust_list.2, getunwind.2, init_module.2: Add note about the use of syscall(2)
open.2: Remove unused <sys/stat.h>
openat2.2: Usesyscall(SYS_...); for system calls without a wrapper;
fix includes too
perf_event_open.2: Usesyscall(SYS_...); for system calls without a
wrapper
pidfd_getfd.2: Usesyscall(SYS_...); for system calls without a
wrapper
pidfd_open.2: Usesyscall(SYS_...); for system calls without a wrapper pidfd_send_signal.2: Usesyscall(SYS_...); for system calls without a
wrapper. Fix includes too
pipe.2: wfix
pivot_root.2: Usesyscall(SYS_...); for system calls without a wrapper poll.2: Remove <signal.h>
process_madvise.2: Usesyscall(SYS_...); for system calls without a
wrapper. Fix includes too.
quotactl.2: Better detail why <xfs/xqm.h> is included readdir.2: Usesyscall(SYS_...); for system calls without a wrapper readlink.2: ffix
reboot.2: Usesyscall(SYS_...); for system calls without a wrapperman2/alloc_hugepages.2 | 5 +++++ man2/arch_prctl.2 | 6 ++++++ man2/capget.2 | 5 +++++ man2/clone.2 | 6 ++++++ man2/delete_module.2 | 6 ++++++ man2/exit_group.2 | 6 ++++++ man2/futex.2 | 21 +++++++++++---------- man2/get_robust_list.2 | 5 +++++ man2/getdents.2 | 20 +++++++++++++++----- man2/getunwind.2 | 6 ++++++ man2/init_module.2 | 5 +++++ man2/io_destroy.2 | 16 +++++++++------- man2/io_getevents.2 | 21 +++++++++++---------- man2/ioctl_tty.2 | 6 +++--- man2/ioctl_userfaultfd.2 | 1 + man2/ioperm.2 | 2 +- man2/ioprio_set.2 | 15 +++++++++------ man2/ipc.2 | 19 ++++++++++++------- man2/kcmp.2 | 18 ++++++++++-------- man2/kexec_load.2 | 24 +++++++++++++----------- man2/keyctl.2 | 17 +++++++---------- man2/link.2 | 2 +- man2/llseek.2 | 13 +++++++------ man2/lookup_dcookie.2 | 14 +++++++++----- man2/membarrier.2 | 16 ++++++++++------ man2/mincore.2 | 1 - man2/mknod.2 | 2 -- man2/mmap2.2 | 10 ++++++---- man2/modify_ldt.2 | 15 ++++++++++----- man2/mq_getsetattr.2 | 15 ++++++--------- man2/open.2 | 1 - man2/openat2.2 | 20 +++++++++++--------- man2/perf_event_open.2 | 21 +++++++++++---------- man2/pidfd_getfd.2 | 14 +++++++++----- man2/pidfd_open.2 | 13 ++++++++----- man2/pidfd_send_signal.2 | 16 ++++++++++------ man2/pipe.2 | 4 ++-- man2/pivot_root.2 | 14 +++++++++----- man2/poll.2 | 3 +-- man2/process_madvise.2 | 20 ++++++++++++-------- man2/quotactl.2 | 4 +++- man2/readdir.2 | 12 +++++++----- man2/readlink.2 | 2 +- man2/reboot.2 | 12 +++++++----- scripts/bash_aliases | 1 + 45 files changed, 293 insertions(+), 182 deletions(-)
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/